2009年12月5日星期六

How to adjust zoom automatically in gmap (自动调整zoom值的方法)

We just need to use the object GLatLngBounds in Google Map API.

Exmaple:
var bounds = new GLatLngBounds();

//Repeat the following lines,add all makers' latitude and longitude into bounds object
var point = new GLatLng(parseFloat(marker_latitude),parseFloat(marker_longitude));
bounds.extend(point);

//The gmap here is the GMap2 Object you have defined. (这里的gmap就是你的GMap2对象。)
//Of couse, you can use gmap.getBoundsZoomLevel(bounds) +/- n to modify the zoom you like.
gmap.setZoom(gmap.getBoundsZoomLevel(bounds));

PS: If the zoom>12, there will be same shades on the kililfi map.(http://pg03.anypg.com/plan)
(关于非洲地图上的阴影问题,把默认的最大zoom值改成12就行了。)
Example:
var zoom = gmap.getBoundsZoomLevel(bounds);
if(zoom>12)
zoom = 12

Note: the larger the zoom value is, the more detail will be showed on the map.
(注意:zoom值越大,地图被放大的倍数也越大)

没有评论:

发表评论