Anand Thakkar Anand Thakkar - 1 year ago 78
HTML Question

how to auto refresh div after every 1 min that contain map

i am new to stack overflow.please edit my question if it looks wrong.
i have div tag with id="map" that contain google map i want to refresh that div at every 1 min.

<div id="map" style="width: 100%; height: 500px"></div>

function load() {

var map = new google.maps.Map(document.getElementById("map"), {
center: new google.maps.LatLng("<?php echo $lat;?>", "<?php echo $lng;?>"),
zoom: 13,
mapTypeId: 'roadmap'
var infoWindow = new google.maps.InfoWindow;

// Change this depending on the name of your PHP file
downloadUrl("mapajax.php", function(data) {
var xml = data.responseXML;

var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var name = markers[i].getAttribute("name");
var email = markers[i].getAttribute("email");
var phone = markers[i].getAttribute("phone");
var status = markers[i].getAttribute("status");
var type = markers[i].getAttribute("type");
var point = new google.maps.LatLng(
var html = "<b>" + name + "</b> <br/>" + email+ "</b> <br/>" + phone+ "</b> <br/>" + status;
var icon = customIcons[type] || {};
var marker = new google.maps.Marker({
map: map,
position: point,
icon: icon.icon
bindInfoWindow(marker, map, infoWindow, html);

Answer Source

you can use setinterval for every sec. refresh like below , off course you can edit the function according to your need like 1 sec = 1000 ms, you can use 60000 for 1 min

}, 60000);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download