看看這個:如何通過Google地圖v3中的幾何庫指示某個點位於圓形或矩形內?
if(google.maps.geometry.poly.containsLocation(new google.maps.LatLng(arrayLatitude[counter1], arrayLongitude[counter1]), polygon))
{
}
這是爲了表明一個點在多邊形或裏面沒有的條件。 我正在尋找類似的東西,但對於圓形或矩形。
是這樣的:
if(google.maps.geometry.circle.containsLocation(new google.maps.LatLng(arrayLatitude[counter1], arrayLongitude[counter1]), circle)
{
}
或爲矩形:
if(google.maps.geometry.rectangle.containsLocation(new google.maps.LatLng(arrayLatitude[counter1], arrayLongitude[counter1]), rectangle)
{
}
謝謝。我需要一些東西來處理'幾何'庫。可以? –
不是。它是非標準的GM功能。只需創建對象(圓或矩形與您需要的參數,並調用方法來檢查內部圖中的點)。可能我不明白問題,對不起?你能舉例說明你在jsbin或plunker上需要什麼嗎? –
我想要一個像這樣的方法:var distanceInMetres = google.maps.geometry.spherical.computeDistanceBetween(latLngCircleCenter,latLngPoint);它工作嗎? –