question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error while drawing a polygon, edition or deleting.

See original GitHub issue

Hello, I don’t kow if the problem comes from my code but every time I draw a polygon, edit a form or delete one I’ve got got this error :

leaflet.draw.js:9 Uncaught TypeError: Cannot read property ‘updatePosition’ of null

After that if I zoom in or out, my polygon never updates it’s size.

Here is my code:

angular.module('myApp.view1', ['ngRoute', 'leaflet-directive'])
.controller('View1Ctrl', ["$scope", "leafletData", function ($scope, leafletData) {

   var drawnItems = new L.FeatureGroup();

    var options = {
        edit: {
            featureGroup: drawnItems
        },
        draw: {
            polyline: false,
            marker: false,
            polygon: {
                shapeOptions: {
                    color: 'purple'
                }
            },
            circle: {
                shapeOptions: {
                    stroke: true,
                    weight: 4,
                    color: 'blue',
                    opacity: 0.5,
                    fill: true,
                    fillColor: null, //same as color by default
                    fillOpacity: 0.2,
                    clickable: true
                }
            }
        },
        showRadius: true
    }
    var drawControl = new L.Control.Draw(options);

    angular.extend($scope, {
        defaults: {
            scrollWheelZoom: false
        },
        london: {
            lat: 51.505,
            lng: -0.09,
            zoom: 8
        },
        controls: {
            custom: [drawControl]
        }
    });

    leafletData.getMap().then(function (map) {
        map.addLayer(drawnItems);
        map.on('draw:created', function (e) {
            var type = e.layerType,
                layer = e.layer;

            if (type == "polygon") {
                console.log("polygon " + JSON.stringify(layer.toGeoJSON()));
            }
            if (type === 'circle') {
                console.log(JSON.stringify(layer.toGeoJSON()));
            }

            drawnItems.addLayer(layer);
        });

    });
}]);

Thank you for the help

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:20 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
themrecommented, Jul 20, 2017

I tried using existing geojson on map and I get cannot get ‘lat’ of undefined: https://jsfiddle.net/Lscupxqp/31/

0reactions
bdoyle522commented, Oct 13, 2017

I have the exact same issue as @themre. Has this been addressed in another thread?

Edit: Upgraded from v0.2.3 to v0.4.10, seems like the bug was addressed and fixed

Read more comments on GitHub >

github_iconTop Results From Across the Web

Polygon lines and attributes disappearing after ed...
Hello, I am having an issue with ARCGIS pro. ... Polygon lines and attributes disappearing after editing or drawing.
Read more >
Error while trying to delete/edit shape using leaflet draw - ESRI
I get the following error when trying to edit the shape created. I'm using leaflet 1.0-rc1 and leaflet draw version 0.3.2. enter image ......
Read more >
Common errors that may occur during editing—Help
Errors that may occur when you start editing · Projected coordinate systems · Coordinates or measures are out of bounds · The spatial...
Read more >
Create Polygon Topology - Set Error Markers dialog box
Use this dialog box to specify how to mark errors in your polygon topology. If you mark errors with blocks, specify the size,...
Read more >
Fix Google Earth errors
Select the problem you'd like to fix. Repair problems with Google Earth Pro To more easily do things like clear your cache or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found