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

161
Vistas
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 Respuestas
Responde la pregunta

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 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