0

I am using the following code to zoom to view all point on a MapView:

mMapController.zoomToSpan(myOverlay.getLatSpanE6(), myOverlay.getLonSpanE6());

It works, except a problem that it only considers points but not overlays, thus gives me the following result:

problem illustration

Is there anyway to deal with this? I was thinking that manually add/subtract some latitude/longitude to/from getLatSpanE6()/getLonSpanE6(), but this is going to be dirty and I don't know how much should I add/subtract. Does anyone have any ideas?

Thanks!

Heuristic
  • 5,087
  • 9
  • 54
  • 94

2 Answers2

1

Refer to my answer here

The only thing you have to do different is take into account the height of the overlay item and its width.

i.e pseudo-code :

projection of (latitude) + width of one overlay 

projection of (longitude) + height of one overlay 
Community
  • 1
  • 1
Reno
  • 33,594
  • 11
  • 89
  • 102
  • Thanks for your reply, but where do I add width and height if I use getLatSpanE6/getLonSpanE6? The geo position is read from a database and I need to use: new GeoPoint((int)(latitude * 1e6), (int)(longitude * 1e6)) to convert it to the one Google API accepts, do I add them to zoomToSpan(latSpan + width, lonSpan + height)? Thanks! – Heuristic Jun 15 '11 at 23:17
-1
mapView.setBuiltInZoomControls(true);
MapController mapcontroller = mapView.getController();
mapcontroller.animateTo(gp);
mapcontroller.setCenter(point)
mapcontroller.setZoom(9);

set the value of the given method according to your requirement if you want more clarity in the answer then first you should read the google documentation for android related to the givn method then you understand. I hope you got solution of your problem using it.

DynamicMind
  • 4,240
  • 1
  • 26
  • 43
  • I did not know the exact position of those pin points at first, so I used zoomToSpan to make all of them visible in one scree, thus I cannot determine what "center" and what zoom level should I use. – Heuristic Jun 15 '11 at 07:55
  • I don't see how this answer relates to the question – Dmitry Zaytsev Nov 11 '15 at 09:31