Prova così
Codice PHP:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script src="http://maps.google.com/maps?file=api&v=2.x&key=ABQIAAAAvvp5_0DlX_WgW_rUar8MaRRNFYGEXFHR2wFQ-ApwAJmf_coUyRTAEpObsxc5VBaAJwyup_6UsxZOKQ" type="text/javascript"></script>
<script type="text/javascript">
var map = null;
var geocoder = null;
var icon = icon;
function load() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(40.727356,13.909893), 13);
icon = new GIcon();
icon.image = "http://www.sitomio.com/fig/marker.gif";
icon.iconSize = new GSize(23, 34);
icon.iconAnchor = new GPoint(6, 20);
icon.infoWindowAnchor = new GPoint(5, 1);
//map.setMapType(G_SATELLITE_MAP );
geocoder = new GClientGeocoder();
}
}
function showAddress(address, hotel) {
if (geocoder) {
geocoder.getLatLng(
address,
function(point) {
if (!point) {
alert(address + " L'indirizzo segnalato per la mappa non è corretto" );
} else {
var marker = new GMarker(point, icon);
map.addOverlay(marker);
//I TRE RIGHI SOTTOSTANTI SERVONO PER CLICCARE SUL MARKER E FAR APPARIRE IL FUMETTO
var html = 'Hotel '+arrayInd[address]+' - Indirizzo: '+address;
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
}
}
);
}
}
var arrayInd = Array();
</SCRIPT>
</head>
<body onload="load();
<?php
include("config.php");
$sql = "select hotel, indirizzo from albergo";
$risultato = @mysql_query($sql,$connessione)
or die("Impossibile eseguire l'interrogazione.");
while ($riga = mysql_fetch_array($risultato)) {
$hotel = $riga['hotel'];
$indirizzo = $riga['indirizzo'];
$indirizzi = "showAddress('$indirizzo'); arrayInd['$indirizzo']='$hotel'; ";
echo $indirizzi;
}
?>
" onunload="GUnload();" topmargin="0" bgcolor="#7ca6ce" leftmargin="0" marginwidth="0" marginheight="0">
<table width="790" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td>
<div id="map" style="width: 790px; height: 550px"></div>
</td>
</tr>
</table>
</body>
</html>