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
| <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
<?php
$indice = 0;
echo "var data = [];\n";
$file = fopen( "http://www.ffffff.com/donnees.txt", "r");
if( $file){
while( !feof( $file)){
$buffer = fgets( $file);
$buffer = preg_replace('/\r\n/', '', $buffer);
$liste = explode(",", $buffer);
if( count( $liste) > 0){
$lon = $liste[1];
$lat = $liste[2];
if( is_numeric( $lon) && is_numeric( $lat)){
echo "data[", $indice ,"]=[", $lon , "," , $lat ,"];\n";
$indice++;
}
}
}
fclose( $file);
}
?>
function initCarte() {
var i, nb = data.length;
var monIconPerso = new google.maps.MarkerImage("IMP.PNG",
/* dimensions de l'image */
new google.maps.Size(4,4),
/* Origine de l'image 0,0. */
new google.maps.Point(0,0),
/* l'ancre (point d'accrochage sur la map) du picto
(varie en fonction de ces dimensions) */
new google.maps.Point(0,0)
);
var oMap = new google.maps.Map(document.getElementById('div_carte'),{
'center': new google.maps.LatLng( 47.363711,1.748199),
'zoom': 8,
'minZoom' : 5,
'maxZoom' :8,
'backgroundColor': '#fff',
'mapTypeId': google.maps.MapTypeId.HYBRID
});
for( i=0; i < nb; i++){
oMarker = new google.maps.Marker
({
'map' : oMap,
icon : monIconPerso,
'position': new google.maps.LatLng( data[i][0], data[i][1])
});
}
}
// init lorsque la page est chargée
google.maps.event.addDomListener(window, 'load', initCarte);
</script>
</head>
<body>
<div id="div_carte"></div>
</body>
</html> |