[GIS] Is it possible to edit draw panel in Leaflet Draw

leafletleaflet-draw

Can i edit leaflet draw panel by adding some new buttons?

For example, i want two buttons for drawing polylines, three for markers and etc.

Best Answer

I don't see any api methods that allow multiple buttons for the same feature type on one draw control. If you need multiple buttons on the same control, then I expect you'll have to modify the source code.

A shortcut would be to add two draw controls to the map. The following works if you paste it into the console of the example

var drawControl2 = new L.Control.Draw({
    draw: {
        position: 'topleft',
        polygon: {
            title: 'Draw a sexy polygon!',
            allowIntersection: false,
            drawError: {
                color: '#b00b00',
                timeout: 1000
            },
            shapeOptions: {
                color: '#bada55'
            },
            showArea: true
        },
        polyline: {
            metric: false
        },
        circle: {
            shapeOptions: {
                color: '#662d91'
            }
        }
    },
    edit: {
        featureGroup: drawnItems
    }
});
map.addControl(drawControl2);
Related Question