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
| function initMap(iconPerso,adresse,zoomLevel)
{
var zoomPerso=parseInt(zoomLevel);
map = new google.maps.Map(document.getElementById('map_canvas'), {
zoom:zoomPerso,
mapTypeControl: true,
mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}
});
var geocoder = new google.maps.Geocoder();
geocoder.geocode({'address': adresse}, function(results, status) {
if (status === 'OK')
{
map.setCenter(results[0].geometry.location);
new google.maps.Marker({
map: map,
title:"Centrage carte demandé sur : "+adresse,
position: results[0].geometry.location,
draggable: true,
animation: google.maps.Animation.DROP});
}
else
{
window.alert('Géocodage infructueux pour la raison suivante : ' +status);
}
// chargement des coordonnées des praticiens
$.get('m_geolocmed.php', function(data) {
$(data).find('marker').each(function(){
var m = $(this);
var latlng= { lat:parseFloat(m.attr('lat')), lng:parseFloat(m.attr('lng')) };
var marker = new google.maps.Marker({
position:latlng,
map:map,
icon: iconPerso,
animation: google.maps.Animation.DROP,
draggable:true,
});
var bulle= ['<span class="r">M '+m.attr('nom')+' '+m.attr('prenom')+'</span>',
m.attr('adresse')!=''? m.attr('adresse') : '',
m.attr('tel')!=''? 'Tél Cab. : '+m.attr('tel')+'' : ''].join('<br />');
var infoWindow = new google.maps.InfoWindow({content: bulle, position:latlng});
marker.addListener('click', function(){infoWindow.open(map,marker);})
});
});
});
} |
Partager