<head>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript" src="http://www.borgo-italia.it/mappe/gmaps.js"></script>
<style type="text/css">
#map {
width: 400px;
height: 400px;
float:left;
}
ul.city {
float: left;
list-style-type: none;
}
</style>
</head>
<body>
<?php
$array = array(
"trento" => "46.085614,11.12011",
"verona" => "45.450497,10.99102",
"modena" => "44.654978,10.92001",
"bologna" => "44.50679,11.343269"
);
?>
<script type="text/javascript">
var map;
$(document).ready(function(){
creaMappa("46.085614","11.12011","Trento");
$("ul.city a").click(function(e){
e.preventDefault();
var coord = $(this).attr("href").split(",");
var tit = $(this).html();
creaMappa(coord[0],coord[1],tit);
})
});
function creaMappa(lat,lon,tit) {
map = new GMaps({
div: '#map',
lat:lat,
lng: lon,
mapTypeId: google.maps.MapTypeId.ROADMAP,
zoom: 10
});
map.addMarker({
lat: lat,
lng: lon,
title: tit
});
}
</script>
<div id="map"></div>
<ul class="city">
<?php
foreach ($array as $key => $value) {
echo "<li><a href='" . $value . "'>$key</li>";
}
?>
</ul>
</body>