我是堆叠溢出的新手。如果看起来不对,请编辑我的问题。 我有div标签id =" map"包含谷歌地图我想每1分钟刷新一次div。
<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(
parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
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);
}
});
}
答案 0 :(得分:1)
你可以每秒使用setinterval
。刷新如下,当然你可以根据你的需要编辑功能,如1秒= 1000毫秒,
你可以使用60000 1分钟
setInterval(function(){
load()
}, 60000);