Search code examples
androidgoogle-mapsopenstreetmaposmdroid

get on map finish loading on osm


I'm trying to develop an Android application using open street map. I noticed that osm have a MapListener for the zoom and the scroll but I couldn't find a Listener when it finish loading my offline map. Any suggestions ??


Solution

  • Osmdroid loads only tiles which are currently displayed for specific zoom and bounds of a MapView. So loading is never finished completely, because new tiles are loaded when user or your code manipulates with the displayed area.

    If you need to hook in to the moment when map is loaded for the first time, you should use OnFirstLayoutListener and MapView.addOnFirstLayoutListener method:

    mapView.addOnFirstLayoutListener(new OnFirstLayoutListener() {
        void onFirstLayout(View v, int left, int top, int right, int bottom) {
            //your code
        }
    });