i want move multiple marker in google maps, i successfully found and follow this example http://jsfiddle.net/ThinkingStiff/Rsp22/ but the example show only one marker can move... i attempt to modify the code but not success... this my code...
function initialize() {
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
//makeRequest is function to load data coordinat from db..... success!!
makeRequest('get_locations.php', function(data) {
var data = JSON.parse(data.responseText);
for (var i=0;i<data.lenght;i++){
//document.getElementById("koordinatnya").innerHTML = data[0]['latitude']+","+data[0]['longitude'];
var myLatlng = new google.maps.LatLng(data[i]['latitude'], data[i]['longitude']);
var marker = new google.maps.Marker({
position: myLatlng,
title:"Dari db :" + data[i]['tempat']
});
marker.setMap(map);
moveMarker( map, marker, data[i]['latitude'], data[i]['longitude']);
}
});
}
function moveMarker( map, marker, lat, lng ) {
//delayed so you can see it move
marker.setPosition( new google.maps.LatLng(lat,lng));
map.panTo( new google.maps.LatLng(lat,lng));
}
Can anyone see why this is not doing what i want?
thanks