如何在Google api v3中获取Rectangle div贴图

时间:2016-01-13 07:04:18

标签: jquery google-maps google-maps-api-3 maps

如何在default或bounds_changed事件时获得4个角(lat& lng) Rectangle Point

1 个答案:

答案 0 :(得分:0)

这应该可以,将它放在一个在bounds_changed事件处理程序中调用的函数中:

var bounds = map.getBounds();
var northEastCorner = bounds.getNorthEast();
var southWestCorner = bounds.getSouthWest();

var northWestCorner = {
    lat: northEastCorner.lat(),
    lng: southWestCorner.lng()
};

var southEastCorner = {
    lat: southWestCorner.lat(),
    lng: northEastCorner.lng()
};