有人可以帮助我吗?我正在尝试实现一张包含我的气象站数据的地图。我希望使用谷歌地图以获得良好的视野,但我不明白为什么我的代码正确加载标记但不更新它们:
function initialize() {
var mapOptions = {
zoom: 8,
maxZoom: 12,
minZoom: 4,
streetViewControl: false,
center: new google.maps.LatLng(37.5, 14),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
}
function loadMarker() {
<?php
$query3 = mysql_query("SELECT id,coordinate FROM stazioni WHERE visibilemappa = 1",$conn);
while($riga_c=mysql_fetch_array($query3)) {
if ($riga_c['coordinate']!="") {
echo "var my".$riga_c['id']." = new google.maps.LatLng(".$riga_c['coordinate'].");
";
}
}
$query3 = mysql_query("SELECT * FROM stazioni WHERE visibilemappa = 1",$conn);
while($riga_c=mysql_fetch_array($query3)) {
if ($riga_c['coordinate']!="") echo "var marker".$riga_c['id']." = new google.maps.Marker({
position: my".$riga_c['id'].",
map: map,
icon: 'genera_scritta.php?testo=".str_replace("<br>"," - ",$riga_c['temperatura'])."',
title: '".str_replace("<br>"," - ",$riga_c['localita'])." ".date('l jS \of F Y h:i:s A')."'
});
";
}
?>
}
setTimeout(function() { loadMarker(); }, 3000);
google.maps.event.addDomListener(window, 'load', initialize);
google.maps.event.addDomListener(window, 'load', loadMarker);
我用铬。万分感谢!!