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

160
Views
jQuery Leaflet Find Feature Geometry Type Error

I need get feature geometry type, I can get feature object on leaflet like this

map.eachLayer(function (layer) {
    console.log(layer);
});

This response is like in this screenshot:

layer object

But when I try this

map.eachLayer(function (layer) {
    console.log(layer.feature.geometry);
});

I get this error:

Uncaught TypeError: Cannot read properties of undefined (reading 'geometry')

How can I get type prop in geometry?

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

0

Only imported layers over L.geoJSON(geojson) are having the feature property.

But you can generate the GeoJSON of every layer:

var geojson = layer.toGeoJSON();
console.log(geojson.feature.geometry);

Maybe the layer is also a LayerGroup then you need first to loop through all features:

if(layer instanceof L.LayerGroup){
   layer.toGeoJSON().features.forEach((feature)=>{
      console.log(feature.geometry);
   });
} else {
   var geojson = layer.toGeoJSON();
   console.log(geojson.feature.geometry);
}
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!