mapsforge / vtm

OpenGL vector map library - running on Android, iOS, Desktop and browser.
GNU Lesser General Public License v3.0
272 stars 89 forks source link

[VTM] offline map loading failure, tileSource.getMapInfo() returning null #1117

Closed deepak07dbz closed 6 months ago

deepak07dbz commented 6 months ago

void loadMap(File areaFolder) { //map event receiver mapView.map().layers().add(new MapEventsReceiver(mapView.map()));

//map file source
MapFileTileSource tileSource = new MapFileTileSource();
File mapFile = new File(areaFolder, AREA + ".map").getAbsoluteFile();
tileSource.setMapFile(String.valueOf(mapFile));
Log.d("LOAD", "loadMap: " + mapFile.exists());
VectorTileLayer l = mapView.map().setBaseMap(tileSource);
mapView.map().setTheme(VtmThemes.DEFAULT);
mapView.map().layers().add(new BuildingLayer(mapView.map(), l));
mapView.map().layers().add(new LabelLayer(mapView.map(), l));

//marker's layer
itemLayer = new ItemizedLayer<>(mapView.map(), (MarkerSymbol) null);
mapView.map().layers().add(itemLayer);

//map position
MapInfo mapInfo = tileSource.getMapInfo();
if (mapInfo == null) {
    Log.d("LOAD", "loadMap: null mapinfo");
} else if (mapInfo.boundingBox == null) {
    Log.d("LOAD", "loadMap: bbox is null");
} else {
    GeoPoint mapCenter = tileSource.getMapInfo().boundingBox.getCenterPoint();
    mapView.map().setMapPosition(mapCenter.getLatitude(),

mapCenter.getLongitude(), 1 << 17); setContentView(mapView); } }

//mapFile exists and is a valid file