1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps JavaScript API Example</title>
<script src="http://maps.google.com/maps?file=api&v=2&key=xxxxxxxxxxxxxxxxxxx-ReWCjPf-J1MRWvfzA" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
geocoder = new GClientGeocoder()
function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl()); // contrôle de zoom
map.addControl(new GMapTypeControl()); // contrôle du type (plan/sat)
geocoder.getLatLng("Bourges, France",function(point) { map.setCenter(point, 6) });
//map.setCenter(new GLatLng(49.378797, 2.219238), 10);
//var bureaux = [
//{label:'Lyon',adresse:'5, rue de la republique, Lyon, France'},
//{label:'Paris',adresse:'5 rue de la republique, 75000 Paris'}
//]
for (var i = 0; i < lieux.length; i++) {
addOffice(lieux[i])
}
}
}
var lieux = [
{label:'Lyon',adresse:'5 rue de la republique'},
{label:'Paris',adresse:'5 rue de la republique'},
]
function addOffice(infos) {
geocoder.getLatLng(infos.adresse, function(point) {
if (!point) {
alert(infos.label + ' (' +infos.adresse + ") introuvable");
} else {
var marker = new GMarker(point);
map.addOverlay(marker);
marker.bindInfoWindowHtml("<p style='font-family:sans-serif'><strong>"+infos.label+"</strong><br />"+infos.adresse);
}
} );
}
//]]>
</script>
</head>
<body onload="load()" onunload="GUnload()">
<div id="map" style="width: 800px; height: 600px"></div>
</body>
</html> |
Partager