getBoundsZoomLevel google map api v3

在google map API  3 下 使用getBoundsZoomLevel 会找不到方法,这个方法是version 2里的,在新版本里,可以用

map.fitBounds(bounds);来代替使用。尤其是使用geocoder.geocode() 方法时,返回的results[0].geometry.viewport 就是我们要的bounds.

代码示例:

map.geocoder.geocode({
‘address': address
}, function(results, status){
if (status == google.maps.GeocoderStatus.OK) {
map.gmap.fitBounds( results[0].geometry.viewport);
}
else {
alert(“Geocode was not successful for the following reason: ” + status);
}
});

10 comments to getBoundsZoomLevel google map api v3

Leave a Reply to fushanlang

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Protected by WP Anti Spam