Buonasera a tutti volevo creare una mappa con tutti i punti presi da un db di mysql in rete ho trovato vari script ma non capisco dove sbaglio perche non visualizza la mappa
<?php
mysql_connect('localhost','user','psw') or die(mysql_error());
mysql_select_db('db_name') or die(mysql_error());
$result = mysql_query("SELECT * FROM locazioni") or die(mysql_error());
$count = 0;
echo mysql_num_rows($result);
$row = mysql_fetch_array($result);
?>
<html>
<head>
<style type="text/css">
html, body { margin:0; padding:0; width:100%; height:100%; }
body { background:#FFFFFF; color:#000000; font-family:Arial, Helvetica, sans-serif; font-size:12px; line-height:150%; text-align:center;}
#map { width:100%; height:95%; }
input { width:250px; }
#tooltip { padding:10px; text-align:left; }
#tooltip p { padding:0; margin:0 0 5px 0; }
</style>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript">
var geocoder;
var map;
//var address;
function initialize() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(45.477,9.185);
var address = "20100 Via Milano, Milano";
var myOptions = {
zoom: 14,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canva s"), myOptions);
<?php
while($row = mysql_fetch_array($result)){
?>
geocoder.geocode( { 'address': "<?php echo $row['fldStreet']; ?>"}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
var contentString = '<div id="content">'+
'<div id="siteNotice">'+
'</div>'+
"<h1 id='firstHeading' class='firstHeading'><?php // echo $row['nomeneg']; ?></h1>"+
'<div id="bodyContent">'+
"<p><?php // echo $row['descr']; ?></p>"+
'<p>Scheda Cli: Uluru, <a href="#">'+
'Click To See</a> '+
'</div>'+
'</div>';
var infowindow = new google.maps.InfoWindow({
content: contentString
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});
<?php sleep(1); ?>
} else {
alert("Geocode was not successful for the following reason: " + status);
//setTimeout("wait = true", 2000);
}
});
<?php } ?>
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map"></div>
</body>
</html>
se guardo il sorgente pagina mi fa vedere che la query e l'export dei dati è ok ma non vedo la mappa come mai?
Grazie