Gin*_*Jim 2 javascript google-maps-api-3
要在谷歌地图中绘制一个矩形,我需要先了解西北和东南点以构建一个LatLngbounds.
在我的情况下,我想绘制一个具有特定西北点和大小(例如100米宽和100米高)的矩形.我不知道最重要的一点.
我害怕几何和地质.我知道东南部可以来自一些公式.只是想知道是否有api或简单的方法来做到这一点?
你可以写一个这样的函数:
// Given the LatLng of a northwest corner, and the number of meters to
// measure east and south, return the LatLngBounds for that rectangle
function makeBounds( nw, metersEast, metersSouth ) {
var ne = google.maps.geometry.spherical.computeOffset(
nw, metersEast, 90
);
var sw = google.maps.geometry.spherical.computeOffset(
nw, metersSouth, 180
);
return new google.maps.LatLngBounds( sw, ne );
}
Run Code Online (Sandbox Code Playgroud)
这是一个有效的例子.
| 归档时间: |
|
| 查看次数: |
2442 次 |
| 最近记录: |