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
| <!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" lang="fr" xml:lang="fr">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Maps test</title>
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
<script type="text/javascript">
var carte;
function initialize() {
var myLatlng = new google.maps.LatLng(46.824642494641, 2.02678155899047);
var myOptions = {
zoom: 6,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
carte = new google.maps.Map(document.getElementById("map"), myOptions);
google.maps.event.addListener(carte, 'click', function(event) {
placeMarker(event.latLng);
});
}
function placeMarker(location) {
var clickedLocation = new google.maps.LatLng(location);
var marker = new google.maps.Marker({
position: location,
map: carte
});
var bounds = carte.getBounds();
bounds.extend(location);
carte.fitBounds(bounds);
carte.setCenter(location);
}
</script>
</head>
<body onload="initialize();">
<div id="map" style="width: 600px; height: 450px"></div>
</body></html> |
Partager