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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
| <!DOCTYPE html>
<html lang="fr">
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>DEPLACEMENT DU VEHICULE</title>
<style type="text/css">
html, body {
height : 100%;
margin : 0;
padding : 0;
font-family : Verdana, Arial;
font-size : 1em;
}
h1 {
color : #4488bb;
font-size : 1.3em;
margin : 0;
padding : 0.5em;
border : 1px solid #4488bb;
}
#page {
padding : 0.5em;
}
#div_main {
margin : auto;
width : 800px;
}
#div_carte{
margin : auto;
margin-top : 1.0em;
width : 600px;
height: 600px;
border : 1px solid #c0c0c0;
}
</style>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var tPosition = [
{ 'lat' :45.767299, 'lon' : 4.834329},
{ 'lat' :45.767299, 'lon' : 4.844329},
{ 'lat' :45.767299, 'lon' : 4.854329},
{ 'lat' :45.767299, 'lon' : 4.864329},
{ 'lat' :45.767299, 'lon' : 4.874329},
{ 'lat' :45.767299, 'lon' : 4.884329},
{ 'lat' :45.767299, 'lon' : 4.894329},
{ 'lat' :45.767299, 'lon' : 4.904329},
{ 'lat' :45.767299, 'lon' : 4.914329},
{ 'lat' :45.767299, 'lon' : 4.924329},
{ 'lat' :45.767299, 'lon' : 4.934329},
{ 'lat' :45.767299, 'lon' : 4.944329},
{ 'lat' :45.767299, 'lon' : 4.954329},
{ 'lat' :45.767299, 'lon' : 4.964329},
{ 'lat' :45.767299, 'lon' : 4.974329},
{ 'lat' :45.767299, 'lon' : 4.984329},
{ 'lat' :45.767299, 'lon' : 4.994329},
];
var nbPoint = tPosition.length;
var iPos = 0;
function movePositionMarker( marker){
iPos++; // incrémentation;
iPos %= nbPoint; // pas de débordement
// déplace le marker
marker.setPosition( new google.maps.LatLng( tPosition[iPos].lat, tPosition[iPos].lon));
// rappel de la fonction
setTimeout( function(){
movePositionMarker( marker);
}, 1000);
}
function initCarte(){
// init
var oMap, oMarker;
var mapOptions = {
backgroundColor : '#fff',
mapTypeControl : false,
streetViewControl : false,
zoomControlOptions: {
style: google.maps.ZoomControlStyle.SMALL
},
zoom : 9,
center : new google.maps.LatLng( 45.76, 4.99),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
// creation de la carte
oMap = new google.maps.Map(document.getElementById("div_carte"), mapOptions);
// creation du marqueur
oMarker = new google.maps.Marker({
position : new google.maps.LatLng( tPosition[0].lat, tPosition[0].lon),
map : oMap
});
movePositionMarker( oMarker);
}
// init lorsque la page est chargee
google.maps.event.addDomListener(window, 'load', initCarte);
</script>
</head>
<body>
<div id="page">
<div id="div_main">
<h1>DEPLACEMENT</h1>
<div id="div_carte"></div>
</div>
</div>
</body>
</html> |
Partager