我需要確定某些LatLngs是否位於Google地圖圈內(其中一個爲http://code.google.com/apis/maps/documentation/javascript/overlays.html#Circles)。我該如何解決這個問題?我製作圈子的標記是:計算LatLng與LatLng之間的距離(或圓圈中的點數) - Google Maps v3
geocoder.geocode({ 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
circlemarker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
THEradius = parseFloat(THEradius);
var populationOptions = {
strokeColor: "#BDAEBB",
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: "#BDAEBB",
fillOpacity: 0.5,
map: map,
center: results[0].geometry.location,
radius: THEradius
};
cityCircle = new google.maps.Circle(populationOptions);
map.fitBounds(cityCircle.getBounds());
}
});
我可以使用半徑嗎?
順便說一句,你**不能**使用畢達哥拉斯定理,因爲地球是不平坦的! – kargeor
在網站上的第一個很好的答案,非常感謝,絕對是最好的解決方案和我正在尋找的。你知道這個選項是否有任何請求限制? – rickyduck
該文檔沒有提到任何限制。我不確定該函數是在本地還是在服務器上進行評估。 – kargeor