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
| $('#map').gmap({ 'center': '45.76161017250319,6.284972881353269', 'zoom': 12 }).bind('init', function(ev, map) {
$('#liste_circuits_transports').change(function() {
var ts_selected = $('#liste_circuits_transports').val();
clearMaplayers();
if ( ts_selected!='none' ) {
var layer_ts = new google.maps.KmlLayer('http://monsite.com/media/kml/circuits_ts/'+ts_selected+'.kml' );
layer_ts.setMap(map);
layersdisplayer.push(layer_ts);
$('#map').gmap('clear', 'markers');
google.maps.event.addListener(layer_ts, 'status_changed', function(){
if( this.status == google.maps.KmlLayerStatus.OK){
$.getJSON('http://monsite.com/media/geojson/points_arrets_ts/'+ts_selected+'.geojson').done(function( data ) {
$.each( data["features"], function( key, val ) {
var longitude = val["geometry"]["coordinates"][0];
var latitude = val["geometry"]["coordinates"][1];
var nom_arret = val["properties"]["Nom_arret"];
var horaires = val["properties"]["Horaires"];
var nom_photo = val["properties"]["Lien_photo"];
$('#map').gmap('addMarker', {
'position': new google.maps.LatLng(latitude, longitude),
'icon':'http://monsite.com/media/kml/bus.png'
}).click(function() {
$('#map').gmap('openInfoWindow', { 'content': '<h3>'+nom_arret+'</h3><img src="http://monsite.com/media/kml/photos_arrets_ts/'+nom_photo+'" alt="'+nom_arret+'" title="'+nom_arret+'" /> <br /> <h4>Horaires :</h4> '+horaires }, this);
});
});
});
;
}
});
}
});
}); |
Partager