OSMDroid loads tiles extremely slowly
Asked Answered
S

2

6

I am using osmdroid version 5.6.5 (the latest version), and the tiles of the map (MAPNIK) loads extremely slowly.

This happens on two devices I tried the app on, both with high-speed internet connection (both cellular and WIFI).

It seems like a problem somewhere because there is no way the loading should be that slow

This is the code snippet with the map in the Activity:

@Override
protected void onCreate( Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    appContext = getApplicationContext();

    //important! set your user agent to prevent getting banned from the osm servers
    Configuration.getInstance().load(appContext, PreferenceManager.getDefaultSharedPreferences(appContext));
    setContentView(R.layout.navigation);

    mMapView = (MapView) findViewById(map);
    mMapView.setTileSource(TileSourceFactory.MAPNIK);
    mMapView.setMultiTouchControls(true);
    mMapView.setBuiltInZoomControls(true);

    // add rotation gesture
    mRotationGestureOverlay = new RotationGestureOverlay(this, mMapView);
    mRotationGestureOverlay.setEnabled(true);
    mMapView.setMultiTouchControls(true);
    mMapView.getOverlays().add(this.mRotationGestureOverlay);



    // Set to default location
    IMapController mapController = mMapView.getController();
    mapController.setZoom(15);
    GeoPoint startPoint = new GeoPoint(48.8589654,2.2926013);
    mapController.setCenter(startPoint);
}

I can't seem to find the reason for this slow load. Is there an option to use a simpler map? will that help? Are there any other solutions, something I'm doing wrong?

Thanks.

Supplement answered 7/9, 2017 at 19:55 Comment(2)
Do the tiles load faster in your browser on openstreetmap.org? You could try a different tile source. There can be many reasons for this. Maybe the OSM tile servers are currently having a problem. Maybe just the tile server for your geographical area has a problem. Maybe the access from osmdroid has been rate-limited but this shouldn't be the case for you because it looks like you are setting a different user-agent.Pretonic
@Pretonic The tiles load much faster and smoother on the browser. I have tried using OpenTopo as a tile provider but that loads slow as well. This happens on every geographical location. I can't seem to find the reason why.Supplement
S
3

Try to set the userAgentValue in your Application:

Configuration.getInstance().setUserAgentValue(BuildConfig.APPLICATION_ID);
Stefaniastefanie answered 31/7, 2018 at 14:26 Comment(0)
C
0

For me worked a recommendation appeared in one of the issues. There is an issue on loading HTTPS, so replacing it with a usual HTTP works fine:

map.setTileSource(
    new XYTileSource("HttpMapnik",
            0, 19, 256, ".png", new String[] {
            "http://a.tile.openstreetmap.org/",
            "http://b.tile.openstreetmap.org/",
            "http://c.tile.openstreetmap.org/" },
            "© OpenStreetMap contributors")
);
Contreras answered 27/10, 2019 at 1:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.