opensciencemap / vtm

a vector-tile map library written in java - running on android, desktop and within the browser
GNU Lesser General Public License v3.0
238 stars 176 forks source link

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

Open deepak07dbz opened 3 months ago

deepak07dbz commented 3 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);
        //mapView.map().setMapPosition(18.551576, 73.831151, 1 << 17);
        setContentView(mapView);
        //loadGraph();
    }
}

//mapFile exists and is a valid file

hjanetzek commented 3 months ago

Hello - development is continued at https://github.com/mapsforge/vtm