question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

is there anyway to load PBF tiles in an mbtiles archive offline?

See original GitHub issue

I tried to load Mbtiles file into mapview but failed, nothing is dipsplayed on the map.

        mapView = (MapView) findViewById(map);
        // offline usage
        Timber.plant(new Timber.DebugTree());
        File file = new File(Environment.getExternalStorageDirectory() + "/osmdroid/MbTilesBacNinh.mbtiles");
        Timber.e("File exist? : " + file.exists());
        SimpleRegisterReceiver simpleReceiver = new SimpleRegisterReceiver(this);
        XYTileSource mbtilesRender = new XYTileSource(
                "mbtiles",
                0, 18,  // zoom min/max <- should be taken from metadata if available
                256, ".png", new String[]{});

        IArchiveFile[] files = {MBTilesFileArchive.getDatabaseFileArchive(file)};
        MapTileModuleProviderBase moduleProvider = new MapTileFileArchiveProvider(simpleReceiver, mbtilesRender, files);

        MapTileProviderArray mProvider = new MapTileProviderArray(mbtilesRender, null,
                new MapTileModuleProviderBase[]{moduleProvider}
        );
        mapView.setTileProvider(mProvider);
        mapView.setUseDataConnection(false);
        GeoPoint geoPoint = new GeoPoint(21.049034, 105.873479);
        IMapController mapViewController = mapView.getController();
        mapViewController.setZoom(15);
        mapViewController.setCenter(geoPoint);

Is there any problem with my code? Can anyone please give me an update example which give me the example of the newest version of osmdroid library? If I use private XYTileSource FourUMapsTileSource = new XYTileSource("4uMaps", 0, 18, 256, ".png", new String[]{});, as below:

 mapView.setTileSource(FourUMapsTileSource);
mapView.setUseDataConnection(false);
geoPoint.setCoords(21.049034, 105.873479);
IMapController mapViewController = mapView.getController();
mapViewController.setZoom(15);
mapViewController.setCenter(geoPoint);

everything will be ok. However, I want to load mbtile without knowing the map’s source. Is it possible?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14

github_iconTop GitHub Comments

1reaction
spyhunter99commented, Jun 8, 2017

The default tile provider should just load them. I’ll take a look at it

On Jun 8, 2017 7:20 AM, “Grzegorz Orczykowski” notifications@github.com wrote:

@kingfisherphuoc https://github.com/kingfisherphuoc I have the same problem I can use an example file from http://geoodk.com/mbtiles_howto.html and then everything is ok but it doesn’t work if I use other files eg. from https://www.mapbox.com/help/ define-mbtiles/

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/osmdroid/osmdroid/issues/610#issuecomment-307074822, or mute the thread https://github.com/notifications/unsubscribe-auth/AB4kGaKKAozqqhnsSyUFOzx_eZd1rEboks5sB9j_gaJpZM4Nqrjw .

0reactions
spyhunter99commented, Aug 12, 2017

going to close for now, . pbf support is not trivial.

Read more comments on GitHub >

github_iconTop Results From Across the Web

OSM offline tiles -- mbtiles in openlayers - GIS Stack Exchange
I used tiledownloader to download offline tiles. Now with the new policy acces of mapquest this would be difficult. ... How is it...
Read more >
Leaflet display .mbTiles files in the map - Stack Overflow
I have downloaded UAE mbtiles from openmaptiles site. I need to show the map in offline for UAE. I'm using angular 4. I...
Read more >
How do I create offline layers using MBTiles?
Uploading MBTiles Layers to Fulcrum · From the Fulcrum Layers page click the +New button. · Select MBTiles as the layer type. ·...
Read more >
Using Geofabrik and HOT Export - LearnOSM
The Export Tool allows users to create MBTiles containing tiles from OSM, which can be used as sources of offline context within applications...
Read more >
Fully offline webmap? : r/ArcGIS - Reddit
It delivers esri sceneserver URL from local SLPK and also serves LERC2 TILES from mbtiles, gpkg and zip archive and comes with ArcGIS...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found