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

131
Views
Leaflet marker in polygon

I made a map with Leaflet.js with GeoJSON data and all it's right. But when i want put a marker in a Polygon i cant.

I leave a clipping of my code. Everything works except the marker

          data: squareParkData,
          color: "black",
          fillColor: "green",
          fillOpacity: 0.3,
          weight: 1,
          onEachFeature:onEachFeature,
          pointToLayer: function (feature, latlng) {
            return L.marker(latlng, { icon: municipalDependenceIcon });
          }
        }) ```

Thanks
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

According to the specifications, it seems like the pointToLayer is used for geomtery type 'points'.

Points are handled differently than polylines and polygons

You can use the (onEachFeature's) feature geometries and add a new marker to the layer.

To compute for the center of multiple points, you can use TurfJS https://turfjs.org/docs/#centroid

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