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
| 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 tabMarkers = [];
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: m.attr('genre')==1 ? 'images/female.png' : 'images/male.png',
animation: google.maps.Animation.DROP,
draggable:true,
});
// stockage du marqueur cluster
tabMarkers.push(marker);
var bulle= ['<h3 class="r" style="font-weight:bold;">Dr '+m.attr('nom')+' '+m.attr('prenom')+'</h3>',
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);})
//google.maps.event.addListener(marker,'mouseout', function(){infoWindow.close();});
});
// option pour MarkerClusterer par exemple
var clusterOptions = {
gridSize: 50,
maxZoom: 15,
imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m'
};
// création et affectation du MarkerClusterer
var oCluster = new MarkerClusterer(map, tabMarkers, clusterOptions);
});
});
} |
Partager