[英]How to check if a Latitude/Longitude point is on the GRoute in Google Maps API?
[英]Getting the latitude and longitude of the point in between (by percentage) two points on Google Maps JS API?
这是我到目前为止的代码:
function initialize() {
var mapOptions = {
center: { lat: 21.9072222, lng: -47.715},
zoom: 3
};
var map = new google.maps.Map(document.getElementById('derby-to-lima'),
mapOptions);
var line = new google.maps.Polyline({
path: [new google.maps.LatLng(53.9834124, -1.5863153), new google.maps.LatLng(-12.0553442, -77.0451853)],
strokeColor: "#008CBA",
geodesic: true,
strokeOpacity: 0.5,
strokeWeight: 5,
map: map
});
}
google.maps.event.addDomListener(window, 'load', initialize);
我想在现有线的上方绘制另一条线,该线停在两点之间的点处,可以按百分比更改。 很难解释,但是可以想象,第一点是起点,最后是终点。 您可以通过跑步者当前所占的百分比来了解他们目前的身高。 现在显示它们有多远(假设它们成一直线运行)。
谢谢,我已经坚持了一段时间。
如@ Dr.Molle所建议,加载geometry
库并使用interpolate
方法。
var startPoint = new google.maps.LatLng(53.9834124, -1.5863153);
var endPoint = new google.maps.LatLng(-12.0553442, -77.0451853);
var percentage = 0.5;
var middlePoint = new google.maps.geometry.spherical.interpolate(startPoint, endPoint, percentage);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.