I am very new to creating webmaps with Leaflet and I am trying to save my shapes I draw into my postgis db. I would prefer to be saved as .shp or any default format (i.e. json) with its geometry field. I seek a step-by-step code like a small demo.

the script till now:

var drawnItems = new L.FeatureGroup();

    map.on('draw:created', function (e) {
        var type = e.layerType,
        layer = e.layer;

    polygon_options = {
        allowIntersection: false,
                drawError: {
                    color: '#b00b00',
                    timeout: 1000
                showArea: true,
                metric: false,
                repeatMode: false,
        shapeOptions: {
            stroke: true,
            color: '#6e83f0',
            weight: 4,
            opacity: 0.5,
            fill: true,
            fillColor: null,
            fillOpacity: 0.2,
            clickable: true

    function drawPolygon(){
            var polygonDrawer = new L.Draw.Polygon(map, polygon_options);     
  • Could anyone help with this issue? – Dimitris Floyd Jul 26 '17 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.