我正在使用 Google Maps V3 API 创建一条包含 2 个点的多段线。现在我已经创建了多段线,我想缩短它。
问题:我需要折线从起点延伸到起点和终点之间的中点。我怎样才能做到这一点?
我能找到的最接近的函数是 computeDistanceBetween()
函数,用于查找 2 个 LatLng 点之间的距离。
Javascript 代码
start_latlng = new google.maps.LatLng(42.354183,-71.065063);
end_latlng = new google.maps.LatLng(42.354183,-71.069063);
start_marker = new google.maps.Marker({
position: start_latlng,
map: map
});
end_marker = new google.maps.Marker({
position: end_latlng,
map: map
});
path = [];
path.push(start_latlng);
path.push(end_latlng);
var polyline = new google.maps.Polyline ({
strokeColor: "#970E04",
strokeOpacity: 1.0,
strokeWeight: 2,
path: path,
map: map
})
最佳答案
关于javascript - 在 Google map 中编辑折线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8124488/