Getting map zoom level for given bounds on Android like on JS Google Maps API: map.getBoundsZoomLevel(bounds) -
i have cluster marker defines bounding rectangle containing group of markers. cluster has center (lat,lon), marker count , latitude , longitude span calculate bounds.
the google maps api (js) has function called "getboundszoomlevel(bounds)" cannot find equivalent method in google maps sdk android. how can estimate zoom level given bounds (especially on different devices different resolutions/densitys)?
i've planned user can touch cluster marker , map view centered center , bounds of cluster.
has working code snippet or suggestions me?
thanks in advance regards thorsten.
thank answer solvek. meanwhile found solution i've adapted , works. method computes bounds of set of geo points, computes span of these points , uses zoomtospan , animateto zooming , centering given area:
public static void zoominbounds(final mapview view, final geopoint.. bounds) { int minlat = integer.max_value; int minlong = integer.max_value; int maxlat = integer.min_value; int maxlong = integer.min_value; (geopoint point : bounds) { minlat = math.min(point.getlatitudee6(), minlat); minlong = math.min(point.getlongitudee6(), minlong); maxlat = math.max(point.getlatitudee6(), maxlat); maxlong = math.max(point.getlongitudee6(), maxlong); } final mapcontroller controller = view.getcontroller(); controller.zoomtospan( math.abs(minlat - maxlat), math.abs(minlong - maxlong)); controller.animateto(new geopoint((maxlat + minlat) / 2, (maxlong + minlong) / 2)); }
Comments
Post a Comment