Pregunta

Hola a todos,

Estoy haciendo un mapa de Google con marcadores de los clientes de nuestra empresa, para que los vendedores puedan hacer una guía de viaje fácil. Sin embargo, obtuve muchos marcadores, así que necesito agruparlos para cargarlos correctamente. Ahora encontré algunos sitios que decían que MarkerClusterer era el más rápido de todo, sin embargo, si trato de implementarlo no funciona (no soy Bueno para programar :() Sin embargo, tal vez alguien aquí sepa lo que estoy haciendo mal aquí es el código que estoy usando. Obtener los marcadores del archivo .xml también encontró estos 2 sitios web, sin embargo, incluso con esta ayuda, no puedo Averigüe lo que estoy haciendo mal

http://groups.google.com/group/google-maps-api/browse_thread/thread/a9cd6ed3ae8eBe6/a07a3b9ae7ae196 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>
¿Fue útil?

Solución

¡Debido a Google Maps V2 está en desuso, debe reescribir su código a V3! Aquí encuentras algunos ejemplos de cómo integrar el markerClusterer:Haga clic aquí para referencia

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top