【发布时间】:2014-03-09 02:36:23
【问题描述】:
我正在尝试将折线添加到地图中,但在调用时它们没有出现
这是我的一些代码:
var waypts = [];
var plyLine;
function initialize() {
plyLine = new google.maps.Polyline({
path: waypts,
geodesic: true,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2
});
}
这个函数在 onclick 监听器中被调用
function setWaypts()
{
waypts = [];
plyLine.setMap(null);
for (var i = 0; i < (poiArrayList.length); i++) {
waypts.push(new google.maps.LatLng(poiArrayList[i].mark.getPosition().lat(), poiArrayList[i].mark.getPosition().lng()))
};
plyLine.setMap(map);
}
这是 log(mark.getPosition()) 打印出来的内容:
未捕获的错误:(51.88804094128838,-8.506078720092773)
如果我的代码有问题,任何人都可以停下来吗?
function poi(id, name, description, mark, inv) {
this.id = id;
this.name = name;
this.description = description;
this.mark = mark;
this.inv = inv;
}
var marker = new google.maps.Marker({
position: location,
draggable: false,
map: map,
id: markerId,
icon: iconUrl
});
【问题讨论】:
-
什么是标记?似乎有比您在问题中输入的代码更多的代码。
-
还有很多代码,但我尽量删减了
标签: javascript google-maps polyline