Get all polygon or layer details after polygon draw in leaflet draw

2k Views Asked by At

I am trying to get the layer details of the map which are already overlay on the map. When leaflet draw is created I want to get the layer details (Not the polygon coordinates created by leaflet draw plugin) so that I can use them. I am able to get the coordinates of drawn polygon but that's not what I want.

var draw_layer = new L.FeatureGroup();
mymap.addLayer(draw_layer);
var drawControlFull = new L.Control.Draw({
    draw: {
        polygon: {
          allowIntersection: false, // Restricts shapes to simple polygons
          drawError: {
            color: '#e1e100', // Color the shape will turn when intersects
            message: '<strong>Oh snap!<strong> you can\'t draw that!' // Message that will show when intersect
          },
          shapeOptions: {
            color: '#97009c'
          }
        },
        // disable toolbar item by setting it to false
        polyline: false,
        circle: false,
        rectangle: false,
        marker: false,
        circlemarker: false
        },

    edit: {
        featureGroup: draw_layer,
        remove: true
    }
});
mymap.addControl(drawControlFull);

mymap.on(L.Draw.Event.CREATED, function (e) {
    var type = e.layerType, layer = e.layer;
    
    if(type === 'polygon'){
        var _ajax_cords = [];
        var _coords = layer.getLatLngs()[0];
        $.each(_coords,function(ind,val){
            var _te_co = {x : val.lat, y : val.lng};
            _ajax_cords.push(_te_co);
        });
    }
    
    //if (type === 'polygon') {layer.bindPopup('A popup!');}draw_layer.addLayer(layer);
});

Well I can get the marker detail as I get lot of posts on that but didn't see a post how to get the polygon details.

enter image description here

Any help on this is much appreciable

0

There are 0 best solutions below