Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

370
Views
Google Maps markerClusterer.MarkerClusterer no funciona con geoJSON

¿Alguna idea de por qué mis marcadores no se agrupan? He intentado muchas formas diferentes y nada los agrupará. Me doy cuenta de que podría haber algún problema con los argumentos que estoy pasando al marcadorClusterer, pero no puedo encontrar una manera de hacer que funcione con nada. También hay poca o ninguna documentación sobre markerClusterer.MarkerClusterer (que se requiere cuando se usa unpkg).

 function initMap() { //set map options var myMapOptions = { center: {lat: 40.7498024, lng: -73.9774375}, zoom: 12, } //fill the html div with a map and pass in map options var myNewMap = new google.maps.Map(document.getElementById('mymap'), myMapOptions); //pass in data myNewMap.data.loadGeoJson('missedConnections.geojson'); //define popup windows var infowindow = new google.maps.InfoWindow({maxWidth: 750, autopanMargin: 10,}); //create new popup windows on marker click myNewMap.data.addListener('click', function(event) { console.log(event); // set variables let videourl = event.feature.getProperty('videoURL'); //padding/margin is wonky on mobile vs desktop let html = '<video style="padding-bottom: 5px; padding-right: 3px;" preload="none" autoplay width=" 90%"><source src="' + videourl + '"></video>'; // show the html variable in the infowindow infowindow.setContent(html); infowindow.setPosition(event.latLng); infowindow.setOptions({pixelOffset: new google.maps.Size(0, -30)}); // move the infowindow up 42 pixels to the top of the default marker icon infowindow.open(myNewMap); }); new markerClusterer.MarkerClusterer({myNewMap.data, myNewMap}); }
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

En tu html:

 <script src="https://unpkg.com/@googlemaps/markerclusterer/dist/index.min.js"></script>

En su js, codifique ambos trabajos

 var mc = new markerClusterer.MarkerClusterer({ markers, map });

o

 new markerClusterer.MarkerClusterer({ markers, map });
about 4 years ago · Juan Pablo Isaza Report

0

En primer lugar, está utilizando la taquigrafía de objetos incorrectamente .

En segundo lugar, esa no es la interfaz de la biblioteca.

 const markerCluster = new MarkerClusterer({ map, markers });

donde marcadores es una matriz de google.maps.Markers . Consulte MarkerClustererOptions .

about 4 years ago · Juan Pablo Isaza Report

0

Instancia el markerCluster de esta manera

new MarkerClusterer({ markers: myNewMap.data, map: myNewMap});

recuerda que el objecto ahora recibe un JSON en su constructor y ten en cuenta que ese myNewMap.data debe ser un array de Markers y pues myNewMap el objeto con el que referencias el mapa.

about 4 years ago · Walter Paz Londoño Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!