2016-06-16 56 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 
});