简体   繁体   English

如何获取我的谷歌地图窗口的边界框坐标

[英]How to get Bounding Box coordinates for my google map window

I am working on a project that includes google maps api v3 and PostGres. 我正在开发一个包含谷歌地图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 我已经得到了这个,但这似乎对我不起作用

Finding the lat-long of the corners in a Google Maps window 在Google Maps窗口中查找转角的长度

The question is using the Google Maps API v2, use the Google Maps API v3 equivalent google.maps.Map.getBounds() . 问题是使用Google Maps API v2,使用与Google Maps 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());
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM