谷歌地图地理围栏 - 绘制矩形

时间:2016-06-16 19:24:00

标签: google-maps google-maps-api-3 maps gis google-maps-api-2

我正在尝试使用Google Map API Reference创建Rectangle Geo-fence。我正在使用这个API:

  1. 东北纬度&经度
  2. 西南纬度&经度
  3. 但对于我的项目,我想要所有的4 Vertex Lat。 &安培;长。坐标。请帮我实现这个目标。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

如果你有NE,SW

 North-East Latitude & Longitude = north_lat, east_lng 
 South-West Latitude & Longitude = south_lat, west_lng

你有直接坐标..

伪代码中的

rectangle coord  = (north_lat, west_lng)  
                   (north_lat, east_lng)
                   (south_lat, east_lng) 
                  ( south_lat, west_lng) 
 or using eg: the coords

 var bounds = {
   north: 44.599,
   south: 44.490,
   east: -78.443,
   west: -78.649
};

你可以使用矩形

rectangle = new google.maps.Rectangle({
  bounds: bounds
});
相关问题