2016-06-16 57 views
-1

我正在尝试使用Google地图API参考创建矩形栅栏。使用此API我得到:Google地理栅栏 - 绘制矩形

  1. 东北纬度经度&
  2. 西南纬度经度&

但对于项目中,我希望所有的4顶点纬度。 &长。坐标。请帮我实现这一点。任何帮助,将不胜感激。

回答

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 
});