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 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| <!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="UTF-8">
<link href="/style.css" rel="stylesheet" type="text/css" media="all">
<title>Entrega 5 - BBDD</title>
<style>
#map {
height : 600px;
width : 600px;
margin : 20px;
border : 1px solid #888;
}
</style>
<script src="http://maps.googleapis.com/maps/api/js"></script>
<script>
function initCarte(){
var map = new google.maps.Map( document.getElementById('map'),{
'center' : new google.maps.LatLng( 46.80, 1.70),
'zoom' : 16
});
if (navigator.geolocation)
var watchId = navigator.geolocation.watchPosition(localizacion,null,{enableHighAccuracy:true});
else
alert("Votre navigateur ne prend pas en compte la géolocalisation HTML5");
function localizacion(position){
map.panTo(new google.maps.LatLng(position.coords.latitude, position.coords.longitude));
var marker = new google.maps.Marker({
position: new google.maps.LatLng(position.coords.latitude, position.coords.longitude),
map: map
});
}
google.maps.event.addListener(map, 'click', function (event) {
new google.maps.Marker({
map: map,
position: new google.maps.LatLng(event.latLng.lat(), event.latLng.lng())
});
});
}
google.maps.event.addDomListener( window, 'load', initCarte);
</script>
</head>
<body>
<h1>Geolocalisation et Carte</h1>
<button onclick="javascript:location.reload();" id="button">Borrar todas las rutas y marcadores</button>
<div id="map"></div>
</body>
</html> |
Partager