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.

Mickey
  • 1,405
  • 2
  • 13
  • 33
  • Do the tiles load faster in your browser on http://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. – scai Sep 08 '17 at 07:49
  • 1
    @scai 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. – Mickey Sep 08 '17 at 08:23

2 Answers2

3

Try to set the userAgentValue in your Application:

Configuration.getInstance().setUserAgentValue(BuildConfig.APPLICATION_ID);
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")
);
mspnr
  • 416
  • 4
  • 12