Hey everyone,
I have a question on javascript setTimeout method. I am trying to update google markers at intervals of 10 and 15 questions using setimeout. The marker that has a timeout of 15 seconds loads while the marker for 10 seconds doesnt. I i run the marker for 10 seconds independently, the correct results are achieeved. Any clarifications will be appreciated.
My code
var first_interval = window.onload = function(){
setTimeout(initMap1, 15000);
};
var second_interval = window.onload = function(){
setTimeout(initMap2, 25000);
};
function initMap1() {
var myOptions = {
zoom: 16,
center: new google.maps.LatLng(-1.300355, 36.773855),
mapTypeId: "roadmap"
};
map = new google.maps.Map(document.getElementById('map_canvas_2'), myOptions);
marker = new google.maps.Marker({
position: new google.maps.LatLng(-1.300355, 36.773855),
title: "Your driver",
visible: true,
map: map,
});
var infowindow = new google.maps.InfoWindow({
content: '<div><div>' + cancelled + ' </div><div>'
});
infowindow.open(map);
}
function initMap2() {
var myOptions = {
zoom: 16,
center: new google.maps.LatLng(-1.300355, 36.773850),
mapTypeId: "roadmap"
};
map = new google.maps.Map(document.getElementById('map_canvas_2'), myOptions);
marker = new google.maps.Marker({
position: new google.maps.LatLng(-1.291879, 36.778389),
title: "Your driver",
visible: true,
map: map,
icon: image,
});
var infowindow = new google.maps.InfoWindow({
content: '<div><div>' + driver_name_2 + ' </div><div>' + marker.position + '</div></div>'
});
infowindow.open(map,marker);
}