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

230
Vistas
How to enable labels and contours for various layers (geoJson) in leaflet?

I'm writing a web-viewer with Leaflet using multiple layers (some with Tiles and some with geosjson contours) that I had processed using GDAL. I'd like to display a label with the value of the contour when I activate the respective layer, and disable it when it is not visible. The same with all contour layers. I have tried this code but the labels are displayed at load, without hiding if I deactivate the layer.

L.geoJson(mydataset, 
{onEachFeature: function(feature, layer) {
    var label = L.marker(layer.getBounds().getCenter(), {
      icon: L.divIcon({
        className: 'label',
        html: feature.properties.MY_VARIABLE,
        iconSize: [100, 40]
      })
    }).addTo(map);
  }
});

I know that }).addTo(map) could be the cause of that. Thanks for the suggestions

about 4 years ago · Juan Pablo Isaza
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