Jump to content

dav3net

Membre
  • Posts

    2
  • Joined

  • Last visited

Community Answers

  1. dav3net's post in API Gmaps - Clustering de markers contenu dans une base de donnée MySQL was marked as the answer   
    Merci Sstephane !!



    Entre temps Google m'a répondu ici : https://code.google.com/p/gmaps-api-issues/issues/detail?id=8478&thanks=8478&ts=1439665354

    (je n'ai pas réussi à faire fonctionner le code mis en réponse mais celui-ci est ok sur https://github.com/googlemaps/js-marker-clusterer/tree/gh-pages/examples)

    Pour ceux à qui cela peut servir :


    // Change this depending on the name of your PHP file
    downloadUrl("phpsqlajax_genxml3.php", function(data) {
    var xml = data.responseXML;
    var clusteredmarkers = [];
    var markers = xml.documentElement.getElementsByTagName("marker");
    for (var i = 0; i < markers.length; i++) {
    var name = markers[i].getAttribute("name");
    var address = markers[i].getAttribute("address");
    var type = markers[i].getAttribute("type");
    var point = new google.maps.LatLng(
    parseFloat(markers[i].getAttribute("lat")),
    parseFloat(markers[i].getAttribute("lng")));
    var html = "<b>" + name + "</b> <br/>" + address;
    var icon = customIcons[type] || {};
    var marker = new google.maps.Marker({
    map: map,
    position: point,
    icon: icon.icon,
    shadow: icon.shadow
    });
    clusteredmarkers.push(marker);
    bindInfoWindow(marker, map, infoWindow, html);
    }
    var markerCluster = new MarkerClusterer(map,clusteredmarkers);//this also add the cluster to the map
    });
    }




    Ne pas oublier d'initialiser le script de clustering :


    <script>
    var script = '<script type="text/javascript" src="src/markerclusterer';
    if (document.location.search.indexOf('compiled') !== -1) {
    script += '_compiled';
    }
    script += '.js"><' + '/script>';
    document.write(script);
    </script>




    dont vous trouverez la source ici https://github.com/googlemaps/js-marker-clusterer

    Bon dev à tous !
×
×
  • Create New...