Hunzla Ali
Hunzla Ali

Reputation: 423

How to check leaflet map has any polygon?

I am using leaflet map, which can contain polygon(s). I want to check that map has any polygon and if it has then i want to find coordinates of that polygon?

Upvotes: 0

Views: 2359

Answers (1)

Falke Design
Falke Design

Reputation: 11338

map.eachLayer(function(layer){
    if(layer instanceof L.Polygon && !(layer instanceof L.Rectangle) ){
        console.log(layer.getLatLngs());
    }
});

Upvotes: 3

Related Questions