2012-05-07 124 views
0

我需要找到以千米爲單位的谷歌地圖半徑(可見區域)。你能舉一些例子嗎? 我試圖 `谷歌地圖半徑

var bounds = new google.maps.LatLngBounds(); 
var sw = bounds.getSouthWest(); 
var ne = bounds.getNorthEast(); 

var proximitymeter = google.maps.geometry.spherical.computeDistanceBetween (sw, ne); 

`

但它返回每次

回答

1

你發現的橫截面距離相同的值。這將確定所示地圖的垂直和水平距離。

var bounds = new google.maps.LatLngBounds(); 
var sw = bounds.getSouthWest(); 
var ne = bounds.getNorthEast(); 
var east = new google.maps.LatLng(0, ne.lng()); 
var west = new google.maps.LatLng(0, sw.lng()); 
var north = new google.maps.LatLng(ne.lat(), 0); 
var south = new google.maps.LatLng(sw.lat(), 0); 
var width = google.maps.geometry.spherical.computeDistanceBetween(east, west); 
var height = google.maps.geometry.spherical.computeDistanceBetween(north, south); 

從這裏你可以找到「半徑」。