Leaflet / Leaflet.draw

Vector drawing and editing plugin for Leaflet
https://leaflet.github.io/Leaflet.draw/docs/leaflet-draw-latest.html
MIT License
1.97k stars 992 forks source link

No polygon edit with leaflet beta 1 #434

Open GeoTimber opened 9 years ago

GeoTimber commented 9 years ago

Hello, I wonder if there is a date for support for the leaflet 1 beta?

I don't seem to be able to go into edit mode for polygons with the leaflet beta 1, it works fine on 0.7.4. It says Lat,Lng not defined.

thanks for the nice work!

IvanSanchez commented 9 years ago

Have you tried the leaflet-master branch?

GeoTimber commented 9 years ago

no not yet but I will give it a go, and let you know

GeoTimber commented 9 years ago

Nope not on master either, (at least the dev master one I plucked from here http://leafletjs.com/download.html):

Uncaught TypeError: Cannot read property 'lng' of nullL.Projection.LonLat.project @ leaflet-src-master.js:1441L.CRS.latLngToPoint @ leaflet-src-master.js:1496L.Map.L.Evented.extend.project @ leaflet-src-master.js:2045L.Edit.Poly.L.Handler.extend._getMiddleLatLng @ leaflet.draw-src.js:1380L.Edit.Poly.L.Handler.extend._createMiddleMarker @ leaflet.draw-src.js:1313L.Edit.Poly.L.Handler.extend._initMarkers @ leaflet.draw-src.js:1211L.Edit.Poly.L.Handler.extend.addHooks @ leaflet.draw-src.js:1160L.Handler.L.Class.extend.enable @ leaflet-src-master.js:7225L.EditToolbar.Edit.L.Handler.extend._enableLayerEdit @ leaflet.draw-src.js:2792L.LayerGroup.L.Layer.extend.eachLayer @ leaflet-src-master.js:4808L.EditToolbar.Edit.L.Handler.extend.addHooks @ leaflet.draw-src.js:2687L.Handler.L.Class.extend.enable @ leaflet-src-master.js:7225L.EditToolbar.Edit.L.Handler.extend.enable @ leaflet.draw-src.js:2665L.DomEvent._on.handler @ leaflet-src-master.js:6857

ghost commented 9 years ago

leaflet-master draw with leaflet 1.0 Cannot read property 'lat' of null L.Projection.SphericalMercator.project @ leaflet.1.0.dev.full.js?0a13b9ce:1468

codeofsumit commented 8 years ago

tried it as well for the past two days, especially with L.geoJson. Haven't been able to make it work yet.

GeoTimber commented 8 years ago

It works in the latest stable, I have used that as a work around and swap versions when I need too...

El 2015-11-11 11:15, Sumit Kumar escribió:

tried it as well for the past two days, especially with L.geoJson. Haven't been able to edit a polygon yet.

Reply to this email directly or view it on GitHub [1].

POQUEIRAWEB.COM [2]

IDEAS@POQUEIRAWEB.COM

This message was sent with Roundcube, free open-source software licensed with the GNU General Public License 3 Version 3.

Our office is 100% solar powered.

Links:

[1] https://github.com/Leaflet/Leaflet.draw/issues/434#issuecomment-155723096 [2] http://poqueiraweb.com [3] https://www.gnu.org/licenses/gpl.html

olemartinorg commented 8 years ago

Doesn't work with the latest commit on leaflet-master and Leaflet 1.0.0-beta2. I'm getting this when i click the 'cancel' button when editing a polygon:

Function File
Uncaught TypeError: Cannot read property '0' of undefined @ leaflet.src.js:5541
L.Polyline.L.Path.extend._projectLatlngs @ leaflet.src.js:5541
L.Polyline.L.Path.extend._projectLatlngs @ leaflet.src.js:5553
L.Polyline.L.Path.extend._projectLatlngs @ leaflet.src.js:5553
L.Polyline.L.Path.extend._project @ leaflet.src.js:5525
L.SVG.L.Renderer.extend._updatePath @ leaflet.src.js:6035
L.Path.L.Layer.extend.redraw @ leaflet.src.js:5136
L.Polyline.L.Path.extend.setLatLngs @ leaflet.src.js:5417
L.EditToolbar.Edit.L.Handler.extend._revertLayer @ leaflet.draw.src.js:2676
(anonymous function) @ leaflet.draw.src.js:2633
L.LayerGroup.L.Layer.extend.eachLayer @ leaflet.src.js:4863
L.EditToolbar.Edit.L.Handler.extend.revertLayers @ leaflet.draw.src.js:2632
L.EditToolbar.L.Toolbar.extend.disable @ leaflet.draw.src.js:2494
handler @ leaflet.src.js:6945
wesweaver commented 8 years ago

Any movement on this? I'm getting the error when I edit as well, but only on polygons. Markers and polylines work fine.

codeofsumit commented 8 years ago

@wesweaver I've created my own plugin that we use in production to draw and edit polygons. It's specifically for Leaflet 1.0 https://github.com/codeofsumit/leaflet.pm

Mightfly commented 8 years ago

It looks as if an extra dimension has been added to 'latlngs' - maybe for 'MultiPolyline'.

Changing line 1326 var latlngs = this._latlngs, to var latlngs = this._latlngs[0],
may be a work-around, although other changes may be needed as well...

catbadger commented 8 years ago

@Mightfly can you post the whole function with changes so i can override it?

chugcup commented 8 years ago

See https://github.com/Leaflet/Leaflet.draw/pull/596

alexgubanow commented 8 years ago

I solved the problem with dragging the rectangle. Here is the code: _move: function(t) { for (var e, i = this._shape.getLatLngs(), o = this._shape.getBounds(), a = o.getCenter(), s = [], r = 0, n = i[0].length; n > r; r++) { e = [i[0][r].lat - a.lat, i[0][r].lng - a.lng]; s.push([t.lat + e[0], t.lng + e[1]]); } this._shape.setLatLngs(s), this._repositionCornerMarkers() }, its move func of rectangle

neacon-mick commented 7 years ago

Is the issue of editing MultiPolygon object solved for you guys? I have updated leaflet to 1.0 and I'm using the latest Leaflet draw. Everything is working great, but when I try to edit MultiPolygon I receive an error: TypeError: Cannot read property 'lat' of null project @ leaflet.js:2008 latLngToPoint @ leaflet.js:2049 project @ leaflet.js:2870 _getMiddleLatLng @ Edit.Poly.js:432 _createMiddleMarker @ Edit.Poly.js:362 _initMarkers @ Edit.Poly.js:177 addHooks @ Edit.Poly.js:128 (anonymous function) @ Edit.Poly.js:38 _eachVertexHandler @ Edit.Poly.js:31 addHooks @ Edit.Poly.js:37 enable @ leaflet.js:10255

PS. I'm starting the edit by triggering the edit in code with layer.editing.enable();

Mightfly commented 7 years ago

I did try the latest update against the latest version of Leaflet and experienced problems, so left it for now due to pressure of other work.

From memory the workaround mostly involved a few changes of this._latlngs to this._latlngs[0], although I also found that I had to force touch events to be disabled as well; my use only being from a desktop; a bit agricultural I know, but sometimes needs must. However, Leaflet and Leaflet.draw are both very useful libraries.

From: neacon-mick [mailto:notifications@github.com] Sent: 26 October 2016 10:42 To: Leaflet/Leaflet.draw Leaflet.draw@noreply.github.com Cc: Mightfly mail@alasdair-scott.net; Mention mention@noreply.github.com Subject: Re: [Leaflet/Leaflet.draw] No polygon edit with leaflet beta 1 (#434)

Is the issue of editing MultiPolygon object solved for you guys?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Leaflet/Leaflet.draw/issues/434#issuecomment-256298717 , or mute the thread https://github.com/notifications/unsubscribe-auth/ATU7Sf969yWzrS-4n56C08zdXkgbck46ks5q3yBggaJpZM4F2aKo . https://github.com/notifications/beacon/ATU7SUesqSQGWgkzPTiPqgwM0JhVHgYmks5q3yBggaJpZM4F2aKo.gif

olemartinorg commented 7 years ago

I'm not having any problems any longer (with this, at least) after upgrading to Leaflet 1.0.1 (stable) and Leaflet.draw 0.4.0.

alexgubanow commented 7 years ago

ok, i am finish my project 2 months ago)) and we can close this topic

neacon-mick commented 7 years ago

I just tried updating to Leaflet 1.0.2 and Leaflet Draw 0.4.6 and still have this problem with editing MultiPolygon objects, so unfortunately this issue is not fixed yet.

chugcup commented 7 years ago

Hey @neacon-mick I never really assumed editing MultiPolygons was a supported feature since there isn't a way to draw a new one with this plugin. Any chance you could make a simple jsfiddle with the task you are trying to accomplish?