I am displaying the user's current position and their intended destination using Google maps, MappingOverlayActivity and ItemizedOverlay.
What is the best way to firstly set the appropriate zoom level so that both locations are displayed on the map on the screen with the maximum area covered by the map, i.e rather than the current location being in the centre, having the centre being in the middle of the 2 points.. Also when the user's current location changes, how can I then recalulate and reset the appropriate zoom level to incorporate the new current location.
You use methods from
MapController
(which you obtain usingmapView.getController()
).Specifically
animateTo
(ormoveTo
), andzoomToSpan
.Assuming you have two GeoPoints
do something like this
so you calculate the span (difference) and center (average) of the points.
For the center of the coordinates you might need to do some math http://en.wikipedia.org/wiki/Centroid