Here is my code(most code from Google's API page).
<script>
var beaches = [
['Bondi Beach', -12.890542, 120.274856, 4],
['Coogee Beach', -12.923036, 520.259052, 5],
['Cronulla Beach', -12.028249, 1221.157507, 3],
['Manly Beach', -12.80010128657071, 1121.28747820854187, 2],
['Maroubra Beach', -33.950198, 121.259302, 1]
];
function setMarkers(map, locations) {
for (var i = 0; i < locations.length; i++) {
var beach = locations[i];
var myLatLng = new google.maps.LatLng(beach[1], beach[2]);
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
title: beach[0],
zIndex: beach[3]
});
}
}
function initialize() {
var mapOptions = {
zoom: 3,
center: new google.maps.LatLng(38.77417, -9.13417),
mapTypeId: google.maps.MapTypeId.SATELLITE
}
var map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
setMarkers(map, beaches);
}
google.maps.event.addDomListener(window, 'load', initialize);
setInterval(function() { setMarkers(map, beaches); }, 5000);
</script>
What I simply want to do is reload only the markers. I tried reloading the map using initialize function but it didn't work. Then I tried to reloading using setMarkers function and still no luck...
Thanks for your help.
-12.80010128657071, 1121.28747820854187
are valid lat/lng coordinates?