Search code examples
androidosmdroid

Offline map using osmdroid does not move to location


I am using osmdroid v.3.0.9 to implement an offline map in my application. I am animating the map to a particular position (latitute, longitude).
The following is the code I am using:

mapView.animateTo(new GeoPoint(lat, long));
mapView.zoomToSpan(lat1 - lat2, long1 - long2);

Solution

  • ZoomToSpan seems not to be working in Osmdroid use the following code may be it will help you.

    mapControl = mapView.getController();
            mapControl.setZoom(15);
            mapControl.setCenter(new GeoPoint((maxLatitude + minLatitude) / 2,
                    (maxLongitude + minLongitude) / 2));