Google Maps Polyline and Marker together

google-maps

Solution

I tested with some bogus data here and there doesn't seem to be a problem. The difference is I'm using `userCoorPath` for the polyline and `userCoor` to set the markers. I'm repeating the information, but they are being used differently. One is an array of LatLngs, the other an array of string and two floats.

http://jsfiddle.net/nSf9N/

Problem

I have this code for polyline which is working perfect. How do i add marker for each of location point? ``` 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); ``` I tried ``` 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)); } } ``` Marker seems missing? Any idea how? Thanks.

Original source