This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

Is fitBounds available in osmdroid?

0

My map will have two markers for routing purpose, now how could i automatically zoom out to the center between those two markers? Is there any alternative approach to fitBounds in osmdroid(or is there fitBounds itself!!)?

Thanks in advance :)

asked 07 Jun '16, 14:14

Arun%20Gowtham's gravatar image

Arun Gowtham
0111114
accept rate: 0%

edited 07 Jun '16, 20:32

aseerel4c26's gravatar image

aseerel4c26 ♦
32.6k18248554


One Answer:

2

There is a solution on Stack Overflow. Basically you have to compute a bounding box by iterating over your markers and calculating min/max lat and lon. Then just call zoomToBoundingBox().

answered 07 Jun '16, 16:58

scai's gravatar image

scai ♦
33.3k21309459
accept rate: 23%

Source code available on GitHub .