2011-10-22 45 views

回答

16

如果你使用谷歌地圖API第3版,那麼你將進行如下:

包括幾何圖形庫到Web頁面Spherical Computations

<script type="text/javascript" 
    src="http://maps.googleapis.com/maps/api/js?libraries=geometry&sensor=false"> 
</script> 

然後你就可以計算:

var point = new google.maps.LatLng(55.623151, 8.48215); 
var spherical = google.maps.geometry.spherical; 
var north = spherical.computeOffset(point, 5000, 0); 
var west = spherical.computeOffset(point, 5000, -90); 
var south = spherical.computeOffset(point, 5000, 180); 
var east = spherical.computeOffset(point, 5000, 90); 

您可以檢查running version on jsfiddle

+0

當我嘗試var north = computeOffset(point,5000,0); \t \t \t \t alert('test:'+ north);我根本沒有戒備?甚至沒有測試:... – Karem

+0

@Karem:幾何函數需要合格。我相應地更新了我的答案。 – Jiri

+0

現在一切都是NaN – Karem

相關問題