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

228
Views
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
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!