1

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.

1 Answer 1

2

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);
1
  • That sounds like good idea! Thank you. I have tried to edit the source code, but had no working result.
    – Kirill
    Commented Feb 18, 2016 at 10:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.