Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OSMDroid loads tiles extremely slowly

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.

like image 784
Mickey Avatar asked Oct 17 '22 06:10

Mickey


1 Answers

Try to set the userAgentValue in your Application:

Configuration.getInstance().setUserAgentValue(BuildConfig.APPLICATION_ID);
like image 105
Александр Кундрюков Avatar answered Oct 21 '22 04:10

Александр Кундрюков