Search code examples
androidzoomingpolygonosmdroid

Set zoom for polygon in osmdroid


I want to show an polygon with osmdroid. The polygon appears but how can is set the correct zoomlevel and zoom-position for this polygon?


Solution

  • BoundingBoxE6 bb = BoundingBoxE6.fromGeoPoints(polygon.getPoints());
    mapView.zoomToBoundingBox(bb, true);
    

    With an important constraint: you cannot do that in onCreate (See osmdroid issue 324)