¿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}); }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 });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 .
Instancia el markerCluster de esta maneranew 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.