【发布时间】:2014-03-22 17:47:25
【问题描述】:
我正在尝试在距离我已经创建的折线的起点一定距离处添加一个标记。 (我有一条带有起点和终点的折线,在这些点上带有标记。我想在距起点的特定距离处添加标记。我尝试使用方法 poly.GetPointsAtDistance(distance) 但显然它不再使用了.我看过不同的帖子和谷歌地图Api,但没有成功。 我有
var line = new google.maps.Polyline({
map: map,
path: [location1, location2],
strokeWeight: 7,
strokeOpacity: 0.8,
strokeColor: "#FFAA00"
});
我有折线的长度
var line_length = google.maps.geometry.spherical.computeLength(line.getPath());)
我有一个创建标记的函数:
function createMarker(map, latlng, title){
var marker = new google.maps.Marker({
position:latlng,
map:map,
title: title
});
我希望能够通过给出从起点的距离 (new_distance) 来创建标记。 在类似的东西:
createMarker(map, line.GetPointAtDistance(new_distance), title);
关于使用什么来替换 GetPointAtDistance 的任何建议
【问题讨论】:
-
只是为了进一步澄清我的问题。我想要的是能够在如下所示的函数中添加标记,例如在 line_length/4 或 line_length/3...等处:createMarker(map, line.GetPointAtDistance(line_length/3), title );
标签: javascript google-maps google-maps-api-3