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
|
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var directionsService = new google.maps.DirectionsService();
var map,geocoder, marker;
/*initialise google MAP V3*/
function init() {
directionsDisplay = new google.maps.DirectionsRenderer();
var maison = new google.maps.LatLng(48.873818, 2.29498386);
var myOptions = {
zoom:14,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: maison
}
map = new google.maps.Map(document.getElementById("div_carte"), myOptions);
directionsDisplay.setMap(map);
directionsDisplay.setPanel(document.getElementById("divRoute"));
geocoder = new google.maps.Geocoder();
centrerCommune();
}
function centrerCommune()
{
if (geocoder) {
geocoder.geocode( { 'address': 'Vielsalm, Belgique'}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
/*ajoute un marqueur à l'adresse choisie*/
map.setCenter(results[0].geometry.location);
if (marker) { marker.setMap(null);}
marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert("Geocode n'a rien trouvé !\n raison : " + status);
}
});
}
} |
Partager