Bonjour,

J'ai vu sur plusieurs discussions le problème que je rencontre mais je n'ai pas réussi à le résoudre.

Je m'explique, j'utilise le clustering pour afficher plusieurs points de ma bdd. Cependant il arrive parfois que je dois afficher 2 points qui ont les mêmes coordonnées, je dois absolument les afficher séparément : ce sont des markers qui ont les mêmes coordonnées mais pas les mêmes informations. Ces markers correspondent à des circuits, et certains circuits ont les mêmes coordonnées de départ mais pas les mêmes informations.

J'ai essayé de faire comme ça :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
SELECT ps_product.id_product, ps_product_lang.name, ps_activite.lat, ps_activite.lng, ps_product_lang.description_short
FROM ps_product, ps_product_lang, ps_activiteproduct, ps_activite
WHERE ps_product.id_product = ps_product_lang.id_product
AND ps_activiteproduct.id_product=ps_product.id_product
AND ps_activiteproduct.id_activite=ps_activite.id_activite
AND ps_activiteproduct.position = 0
AND ps_product.active = 1
ORDER BY ps_activite.lat
--> requête qui récupère les informations, triées par la latitude

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
function load() {
    var options = {
        zoom: 5, //zoom France
        center: new google.maps.LatLng(46.664517, 2.589111) //center France
    };
    var map = new google.maps.Map(document.getElementById("map"), options);
    var infoWindow = new google.maps.InfoWindow();
    downloadUrl("...php", function(data) {
        var xml = data.responseXML;
        var markers = xml.documentElement.getElementsByTagName("product");
        var markersClust = [];
        for (var i = 0; i < markers.length; i++) {//i = 0 et i < length pour avoir tous les markers de position = 0
            var j = i + 1;
            var id_product = markers[i].getAttribute("id_product");
            var name = markers[i].getAttribute("name");
            var domaine = markers[i].getAttribute("domaine");
            var description_short = markers[i].getAttribute("description_short");
            var lat = parseFloat(markers[i].getAttribute("lat"));
            var lng = parseFloat(markers[i].getAttribute("lng"));
            if (lat === parseFloat(markers[j].getAttribute("lat"))) {
                lat === '59';
            }
            var point = new google.maps.LatLng(lat, lng);
            var myMarkerImage = new google.maps.MarkerImage('..bustour.png');
            var marker = new google.maps.Marker({
                position: point,
                icon: myMarkerImage,
                map: map,
                title: name,
                animation: google.maps.Animation.DROP
            });
            markersClust.push(marker);
            for (i = 0; i < markersClust.length; i++)
            {
                markersClust[i];
            }
            var html = "<p style='text-align: justify;'><b>Circuit :</b> " + name + " <a href=" + domaine + ...id_product=" + id_product + "><img src='img/admin/details.gif' title='Voir'/></a><br /><br /><b>Résumé :</b><br />" + description_short + "</p>";
            bindInfoWindow(marker, map, infoWindow, html);
        }
        var markerCluster = new MarkerClusterer(map, markersClust);
    });
 
}
--> ici j'essaie de modifier la latitude (ici 59 juste pour l'exemple) si c'est la même que celle d'après bref je suis un peu perdu ... et j'ai cette erreur : TypeError: markers[j] is undefined

Merci d'avance.