Den*_*ail 2 jquery jquery-plugins
我正在使用jQuery的gMap插件.在我的地图上,我有几个标记.如何根据标记的范围使地图居中?然后,如果可能的话,稍微缩小以在最外面的标记和地图边缘之间留下边距?
谢谢!
编辑1-代码类似于http://gmap.nurtext.de/examples.html中的此示例...
$("#map4").gMap({ markers: [{ latitude: 47.651968,
longitude: 9.478485,
html: "_latlng" },
{ address: "Tettnang, Germany",
html: "The place I live" },
{ address: "Langenargen, Germany",
html: "_address" }],
address: "Braitenrain, Germany",
zoom: 10 });
Run Code Online (Sandbox Code Playgroud)
这可能对你有所帮助......
//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);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5821 次 |
| 最近记录: |