jQuery 如何为我的谷歌地图窗口获取边界框坐标
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15652867/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get Bounding Box coordinates for my google map window
提问by writeToBhuwan
I am working on a project that includes google maps api v3 and PostGres.
我正在开发一个包含 google maps api v3 和 PostGres 的项目。
What I want to do is to pass the bounding box coordinates(bottom left and top right) of my map window to POSTGRES and get the POI locations for the generated map window on a particular zoom level.
我想要做的是将我的地图窗口的边界框坐标(左下角和右上角)传递给 POSTGRES,并在特定缩放级别上获取生成的地图窗口的 POI 位置。
How can I achieve this.. ? Any Ideas? Is there already a direct function for this in api v3?
我怎样才能做到这一点..?有任何想法吗?在 api v3 中是否已经有一个直接的功能?
I've got this on SO but this does not seem to work for me
我在 SO 上有这个,但这似乎对我不起作用
回答by geocodezip
The questionis using the Google Maps API v2, use the Google Maps API v3 equivalent google.maps.Map.getBounds().
该问题是使用谷歌地图API第2版,使用谷歌地图API V3相当于google.maps.Map.getBounds() 。
The bounds will not be available until the bounds_changed event has fired, so wrap it in a listener for bounds_changed
在 bounds_changed 事件触发之前,边界将不可用,因此将其包装在 bounds_changed 的侦听器中
google.maps.event.addListener(map, "bounds_changed", function() {
// send the new bounds back to your server
alert("map bounds{"+map.getBounds());
});