Question

Salut tout le monde,

Je fais une carte Google avec des marqueurs des clients de notre société, de sorte que les ventes peuvent faire un guide de voyage facile. Cependant, j'ai beaucoup de marqueurs, j'ai donc besoin de les regrouper pour les charger correctement. Maintenant que j'ai trouvé quelques sites qui ont déclaré que MarkerClusterner était le plus rapide du tout, si j'essaie de la mettre en œuvre, cela ne fonctionne pas (je ne suis pas Bon à la programmation :() Cependant, peut-être que quelqu'un ici sait ce que je fais mal ici est le code que j'utilise. Faire sortir les marqueurs du fichier .xml a également trouvé ces 2 sites Web, cependant même avec cette aide, je ne peux pas comprendre ce que je fais mal

http://groups.google.com/ Groupe / Google-Maps-Api / Browse_thread / Thread / A9CD6ED3AE8AE6 / A07A3B9AE7AAE196 http://www.svennerberg.com/examples/markers/markerperformance.html#

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  <head>
    <title>Google Maps</title>
    <script src="js/markerclusterer.js" type="text/javascript"></script>
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAAPDUET0Qt7p2VcSk6JNU1sBSM5jMcmVqUpI7aqV44cW1cEECiThQYkcZUPRJn9vy_TWxWvuLoOfSFBw" type="text/javascript"></script>
  </head>
  <body onunload="GUnload()">

    <!-- you can use tables or divs for the overall layout -->


           <div id="map" style="width: 550px; height: 450px"></div>


    <script type="text/javascript">
    //<![CDATA[

    if (GBrowserIsCompatible()) {

      // A function to create the marker and set up the event window
      function createMarker(point,html) {
        var marker = new GMarker(point);
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
        return marker;
      }


      // This function picks up the click and opens the corresponding info window
      function myclick(i) {
        GEvent.trigger(gmarkers[i], "click");
      }


      // create the map
      var map = new GMap2(document.getElementById("map"));
      map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl());
      map.setCenter(new GLatLng( 51.907787,5.359741), 9);
      map.enableScrollWheelZoom();


      // Read the data from example.xml
      GDownloadUrl("test.xml", function(doc) {
        var xmlDoc = GXml.parse(doc);
        var markers = xmlDoc.documentElement.getElementsByTagName("marker");

        for (var i = 0; i < markers.length; i++) {
          // obtain the attribues of each marker
          var lat = parseFloat(markers[i].getAttribute("lat"));
          var lng = parseFloat(markers[i].getAttribute("lng"));
          var point = new GLatLng(lat,lng);
          var html = markers[i].getAttribute("html");
          // create the marker
          var marker = createMarker(point,html);
          map.addOverlay(marker);
          markers.push(marker);
        }
      });
      var markerCluster = new MarkerClusterer(map, markers);
    }

    else {
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }


    //]]>
    </script>
  </body>

</html>

Était-ce utile?

La solution

Étant donné que google maps v2 est obsolète, vous devez réécrire votre code en v3! Vous trouverez ici quelques exemples d’intégration du markerclusterer: Cliquez ici pour référence

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top