我有这个用于折线的代码,它工作得很好。如何为每个位置点添加标记?
var userCoor = [
<?php
for($i=0; $i<sizeOf($lat); $i++)
echo "new google.maps.LatLng({$lat[$i]}, {$long[$i]}),";
?>
];
var userCoordinate = new google.maps.Polyline({
path: userCoor,
strokeColor: "#FF0000",
strokeOpacity: 1,
strokeWeight: 2
});
userCoordinate.setMap(map);
我试过了
var infowindow = new google.maps.InfoWindow();
var marker, i;
for (i = 0; i < userCoor.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(userCoor[i][1], userCoor[i][2]),
map: map
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(userCoor[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
}
}
标记似乎不见了?知道怎么做吗?谢谢。