Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

392
Vistas
MarkerCluster markers are still showing behind cluster

I am trying to hide the markers behind my cluster and only have them show when the marker is clicked.

This is how it appears:

This is how it appears. However when I click the cluster and exit it, it goes back to how it should look (second pic)

However when I click the cluster and exit it, it goes back to how it should look (second pic)

This is how I want it to look originally

(This is how I want it to look originally)

This is my code:

var markers = new L.MarkerClusterGroup();



 

   
                        markers.addLayer(L.marker([currentLatitude, currentLongitude], { icon: populationIcon }).addTo(mymap).bindPopup(
                            `The population of ${thisCountry.countryName} is ${thisCountry.countryPopulation}.`));


                        markers.addLayer(capitalMarker = L.marker([currentLatitude, currentLongitude], { icon: cityIcon }).addTo(mymap).bindPopup(
                            `The capital city of ${thisCountry.countryName} is ${thisCountry.countryCapital}.`));

                        markers.addLayer(carMarker = L.marker([currentLatitude, currentLongitude], { icon: carIcon }).addTo(mymap).bindPopup(
                            `They drive on the ${thisCountry.carSide} of the road in ${thisCountry.countryName}.`));

                        //add cluster to map
                        mymap.addLayer(markers);
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You are adding the created marker to the map too and this is wrong (icon: carIcon }).addTo(mymap).bindPopup().

Change

 markers.addLayer(carMarker = L.marker([currentLatitude, currentLongitude], { icon: carIcon })
  .addTo(mymap)
  .bindPopup(`They drive on the ${thisCountry.carSide} of the road in ${thisCountry.countryName}.`));

to

 markers.addLayer(carMarker = L.marker([currentLatitude, currentLongitude], { icon: carIcon })
  .bindPopup(`They drive on the ${thisCountry.carSide} of the road in ${thisCountry.countryName}.`));
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda