Jquery 如何使用gMap将带有多个标记的地图居中?

Jquery 如何使用gMap将带有多个标记的地图居中?,jquery,jquery-plugins,Jquery,Jquery Plugins,我正在使用jQuery的gMap插件。在我的地图上有几个记号笔。如何基于标记的范围将地图居中?然后,如果可能的话,稍微缩小以在最外面的标记和地图边缘之间留一个边距 谢谢 编辑1-代码类似于此示例,来自 这可能对你有点帮助 //Zoom and center the map to fit the markers //This logic could be conbined with the marker creation. //Just keeping it separate for co

我正在使用jQuery的gMap插件。在我的地图上有几个记号笔。如何基于标记的范围将地图居中?然后,如果可能的话,稍微缩小以在最外面的标记和地图边缘之间留一个边距

谢谢

编辑1-代码类似于此示例,来自


这可能对你有点帮助

//Zoom and center the map to fit the markers  
//This logic could be conbined with the marker creation.  
//Just keeping it separate for code clarity.  
var bounds = new google.maps.LatLngBounds();  
for (index in markers) {  
    var data = markers[index];  
    bounds.extend(new google.maps.LatLng(data.lat, data.lng));  
}  
map.fitBounds(bounds);  
//Zoom and center the map to fit the markers  
//This logic could be conbined with the marker creation.  
//Just keeping it separate for code clarity.  
var bounds = new google.maps.LatLngBounds();  
for (index in markers) {  
    var data = markers[index];  
    bounds.extend(new google.maps.LatLng(data.lat, data.lng));  
}  
map.fitBounds(bounds);