p开发者_运维百科hp noobie here. Would like to seek the help of you guys on the following codes for Google Maps.
I have this javascript that works perfectly fine in plotting the markers. However, there lies a problem where the marker numbers seems to jump. (instead of 1,2,3,4 it jumps like 1,4,5,7). The following are my javascript codes which does the plotting of markers:
<script>
function initialize() {
var centerMap = <?php echo json_encode($locations[0]) ?>;
var centerMap2 = <?php echo json_encode($locations2[0]) ?>;
var locations = <?php echo json_encode($locations) ?>;
var locations2 = <?php echo json_encode($locations2) ?>;
var centerLatlng = new google.maps.LatLng(centerMap, centerMap2);
var map = new google.maps.Map(document.getElementById("map_canvas"), {
zoom: 2,
center: centerLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
});
var marker, i, image, count;
for (i = 0; i < locations.length; i++) {
image = new google.maps.MarkerImage('markers/marker'+i+'.png');
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i], locations2[i]),
icon: image,
map: map
});
}
}
</script>
Could this be a problem where similar co-ordinates are in place which results in the markers replacing each other?
thanks for any kind advices given! :)
精彩评论