gpt4 book ai didi

javascript - 从 LatLng(或圆圈中的点)算出 LatLng 距离 - Google Maps v3

转载 作者:行者123 更新时间:2023-11-30 10:47:51 25 4
gpt4 key购买 nike

我需要查明某些 LatLng 是否在 Google map 圈内(其中之一:http://code.google.com/apis/maps/documentation/javascript/overlays.html#Circles)。我将如何解决这个问题?我制作圆圈的标记是:

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());
}
});

我可以只使用半径吗?

最佳答案

var distance = google.maps.geometry.spherical.computeDistanceBetween(
results[0].geometry.location, otherLatLng);

if (distance <= THEradius) {...} else {...}

希望对你有用。参见 http://code.google.com/apis/maps/documentation/javascript/reference.html#spherical

关于javascript - 从 LatLng(或圆圈中的点)算出 LatLng 距离 - Google Maps v3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7270882/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com