var map;
var infowindow = null;
var markers = [];
// ['Title', lat, lng, z-index, 'html']
var sites = [
["Bar restaurant Le Miracle", "43.914887800000", "4.509963400000", 3, "
", "pointer_color", "30"],["Bar restaurant Le Miracle", "43.914887800000", "4.509963400000", 3, "", "pointer_color", "30"],["CLASSE PRESTIGE", "43.910487000000", "4.519575000000", 3, "", "pointer_color", "100"],["CLASSE PRESTIGE", "43.910487000000", "4.519575000000", 3, "", "pointer_color", "100"],["VILMORIN SA", "43.887651800000", "4.519452400000", 3, "", "pointer_color", "99"],["La Jacambra", "43.913287200000", "4.512222400000", 3, "", "pointer_color", "35"],["La Jacambra", "43.913287200000", "4.512222400000", 3, "", "pointer_color", "35"],["Le Mas de Gleyzes", "43.910131600000", "4.557423200000", 3, "", "pointer_color", "36"],["Lédenon Pizza", "43.909206400000", "4.511826400000", 3, "", "pointer_color", "37"],["ALMEIDA EURL Plomberie Chauffage Climatisation Salle de bain", "43.915408000000", "4.507605000000", 3, "ALMEIDA EURL Plomberie Chauffage Climatisation Salle de bain 30210 Lédenon
Aller à la fiche ", "pointer_color", "43"],["ALMEIDA EURL Plomberie Chauffage Climatisation Salle de bain", "43.915408000000", "4.507605000000", 3, "ALMEIDA EURL Plomberie Chauffage Climatisation Salle de bain 30210 Lédenon
Aller à la fiche ", "pointer_color", "43"],["Côté Parc", "43.915386600000", "4.507873100000", 3, "", "pointer_color", "41"],["Côté Parc", "43.915386600000", "4.507873100000", 3, "", "pointer_color", "41"],["Côté Parc", "43.915386600000", "4.507873100000", 3, "", "pointer_color", "41"],["DESIGN'MOI UNE DÉCO - Décoration et architecture intérieur/extérieur", "43.911232000000", "4.511650000000", 3, "DESIGN'MOI UNE DÉCO - Décoration et architecture intérieur/extérieur13 Chemin de la Jardine
30210 LEDENON
Aller à la fiche ", "pointer_color", "107"],["DESIGN'MOI UNE DÉCO - Décoration et architecture intérieur/extérieur", "43.911232000000", "4.511650000000", 3, "DESIGN'MOI UNE DÉCO - Décoration et architecture intérieur/extérieur13 Chemin de la Jardine
30210 LEDENON
Aller à la fiche ", "pointer_color", "107"],["MELA'NAILS - Esthéticienne à domicile", "43.916213000000", "4.506888000000", 3, "MELA'NAILS - Esthéticienne à domicile1 Rue de l\'Oliverie
30210 LEDENON
Aller à la fiche ", "pointer_color", "106"],["MELA'NAILS - Esthéticienne à domicile", "43.916213000000", "4.506888000000", 3, "MELA'NAILS - Esthéticienne à domicile1 Rue de l\'Oliverie
30210 LEDENON
Aller à la fiche ", "pointer_color", "106"],["Les Gîtes de la Belle Etoile", "43.918972500000", "4.512331300000", 3, "", "pointer_color", "47"],["Les Gîtes de la Belle Etoile", "43.918972500000", "4.512331300000", 3, "", "pointer_color", "47"],["Circuit de Lédenon", "43.915408000000", "4.507605000000", 3, "", "pointer_color", "49"],["Circuit de Lédenon", "43.915408000000", "4.507605000000", 3, "", "pointer_color", "49"],["I@D France", "43.915408000000", "4.507605000000", 3, "", "pointer_color", "51"],["I@D France", "43.915408000000", "4.507605000000", 3, "", "pointer_color", "51"],["ARABESQUE ET COTON - Institut de beauté - Cosmétiques bio", "43.913749000000", "4.509624000000", 3, "ARABESQUE ET COTON - Institut de beauté - Cosmétiques bio2 Traverse des Bassins
30210 LEDENON
Aller à la fiche ", "pointer_color", "108"],["ARABESQUE ET COTON - Institut de beauté - Cosmétiques bio", "43.913749000000", "4.509624000000", 3, "ARABESQUE ET COTON - Institut de beauté - Cosmétiques bio2 Traverse des Bassins
30210 LEDENON
Aller à la fiche ", "pointer_color", "108"],["SARL RG ENERGIES NOUVELLES", "43.910645000000", "4.502247400000", 3, "", "pointer_color", "67"],["SARL RG ENERGIES NOUVELLES", "43.910645000000", "4.502247400000", 3, "", "pointer_color", "67"],["Gite les Coquelicots", "43.910142500000", "4.520323400000", 3, "Gite les Coquelicots17 Chemin de la croix des Soldats
30210 LEDENON
Aller à la fiche ", "pointer_color", "101"],["Gite les Coquelicots", "43.910142500000", "4.520323400000", 3, "Gite les Coquelicots17 Chemin de la croix des Soldats
30210 LEDENON
Aller à la fiche ", "pointer_color", "101"],["TAXI ELA", "43.768000000000", "4.435860000000", 3, "", "pointer_color", "81"],["TAXI ELA", "43.768000000000", "4.435860000000", 3, "", "pointer_color", "81"],["SOLIDARIS ISOLATION", "43.916339000000", "4.507839000000", 3, "", "pointer_color", "90"],["SOLIDARIS ISOLATION", "43.916339000000", "4.507839000000", 3, "", "pointer_color", "90"],["STICKERS SHOP", "43.915035700000", "4.512110400000", 3, "", "pointer_color", "91"],["Jardin clé en main SARL Dépôt Ldt Les Escurières", "47.023667700000", "-0.128243200000", 3, "Jardin clé en main SARL Dépôt Ldt Les Escurières4 rue de l'Oliverie
Aller à la fiche ", "pointer_color", "96"],["Jardin clé en main SARL Dépôt Ldt Les Escurières", "47.023667700000", "-0.128243200000", 3, "Jardin clé en main SARL Dépôt Ldt Les Escurières4 rue de l'Oliverie
Aller à la fiche ", "pointer_color", "96"],["PALMYR Circuit Automobile", "43.923299000000", "4.503632300000", 3, "", "pointer_color", "97"],["PALMYR Circuit Automobile", "43.923299000000", "4.503632300000", 3, "", "pointer_color", "97"],["TERRE D'OLIVIERS", "43.915821000000", "4.516060000000", 3, "", "pointer_color", "109"],["TERRE D'OLIVIERS", "43.915821000000", "4.516060000000", 3, "", "pointer_color", "109"],["GDC Expertise", "43.911340000000", "4.517130000000", 3, "", "pointer_color", "110"],["GDC Expertise", "43.911340000000", "4.517130000000", 3, "", "pointer_color", "110"],["Rôtisserie la Galinette", "43.911340000000", "4.517130000000", 3, "Rôtisserie la Galinette3B Chemin de la croix des soldats
30210 LEDENON
Aller à la fiche ", "pointer_color", "111"],["Rôtisserie la Galinette", "43.911340000000", "4.517130000000", 3, "Rôtisserie la Galinette3B Chemin de la croix des soldats
30210 LEDENON
Aller à la fiche ", "pointer_color", "111"],["Gîte L'Olivier", "43.912530000000", "4.507370000000", 3, "", "pointer_color", "112"],["AGENCE MEDIA", "43.909996517432", "4.522969457670", 3, "", "pointer_color", "113"],["AGENCE MEDIA", "43.909996517432", "4.522969457670", 3, "", "pointer_color", "113"],["COMMUNITY ONLINE", "43.916861091166", "4.515213813494", 3, "", "pointer_color", "115"],["Chez Marc et Cathy", "43.910966819455", "4.517099269497", 3, "Chez Marc et Cathy3 chemin de la croix des soldats Villa n°2
30210 LEDENON
Aller à la fiche ", "pointer_color", "116"],["Chez Marc et Cathy", "43.910966819455", "4.517099269497", 3, "Chez Marc et Cathy3 chemin de la croix des soldats Villa n°2
30210 LEDENON
Aller à la fiche ", "pointer_color", "116"],["Les douceurs de Lolly", "43.914697897682", "4.511404495505", 3, "", "pointer_color", "117"],["Les douceurs de Lolly", "43.914697897682", "4.511404495505", 3, "", "pointer_color", "117"],["Au mazet du parc", "43.914232996929", "4.506627013492", 3, "", "pointer_color", "118"]];
// console.log(sites);
function initialize() {
var mapOptions = {
// Zoom 7 pour voir la corse..
center: {lat: 43.915414, lng: 4.507610},
zoom: 15,
// mapTypeId: google.maps.MapTypeId.ROADMAP,
// Désactivation du zoom avec la roulette de la souris
scrollwheel: false
};
map = new google.maps.Map(document.getElementById('carte'), mapOptions);
// Try HTML5 geolocation
// if(navigator.geolocation) {
// navigator.geolocation.getCurrentPosition(function(position) {
// var pos = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
// map.setCenter(pos);
// }, function() {
// handleNoGeolocation(true);
// });
// } else {
// // Browser doesn't support Geolocation
// handleNoGeolocation(false);
// }
// console.log(markers);
setMarkers(map, sites);
// console.table(markers);
infowindow = new google.maps.InfoWindow({
content: "Chargement..."
});
}
function setMarkers(map, pointers) {
var markers_length = pointers.length;
for (var i = 0; i < markers_length; i ++) {
var sites = pointers[i];
switch (sites[5]) {
case 'pointer_color':
pinColor = "734889";
break;
}
var pinImage = new google.maps.MarkerImage("http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|" + pinColor,
new google.maps.Size(21, 34),
new google.maps.Point(0,0),
new google.maps.Point(10, 34));
var pinShadow = new google.maps.MarkerImage("http://chart.apis.google.com/chart?chst=d_map_pin_shadow",
new google.maps.Size(40, 37),
new google.maps.Point(0, 0),
new google.maps.Point(12, 35));
var siteLatLng = new google.maps.LatLng(sites[1], sites[2]);
var marker = new google.maps.Marker({
position: siteLatLng,
map: map,
title: sites[0],
zIndex: sites[3],
html: sites[4],
icon: pinImage,
categorie: sites[5],
markerId : sites[6],
agenceId : sites[7],
shadow: pinShadow
});
markers.push(marker);
// console.log(marker);
var contentString = '';
google.maps.event.addListener(marker, 'click', function () {
infowindow.setContent(this.html);
infowindow.open(map, this);
});
}
}
function setMapOnAll(map) {
for (key in markers) {
markers[key].setMap(map);
}
}
function showMarkers(map, valeurs) {
setMapOnAll(null);
// test pour inArray, on transforme les objects en tableaux
var checked_categorie = valeurs.categorie;
checked_categorie = Object.keys(checked_categorie);
if (0 == Object.keys(valeurs.categorie).length) {
setMapOnAll(map);
return false;
}
// on boucle sur les markers
for (key in markers) {
// on boucle sur les fonds du marker en cours si une categorie est presente
var categorie_present = false;
if (0 == Object.keys(markers[key].categorie).length || 0 < Object.keys(markers[key].categorie).length && 0 == Object.keys(valeurs.categorie).length) {
categorie_present = true;
} else {
var val_seek = 'categ_' + markers[key].categorie;
if(checked_categorie.indexOf(val_seek) > -1) {
categorie_present = true;
}
}
if (true == categorie_present) {
markers[key].setMap(map);
}
}
}
google.maps.event.addDomListener(window, 'load', initialize);