Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Support for 0.8-dev #257

Open
snkashis opened this Issue · 33 comments

6 participants

@snkashis
Collaborator

Anyone else here running with 0.8-dev yet?

I prepped a branch to begin work on fixing editing (points are not appearing since editing is undefined)...., and taking care of the map not existing when drawstart or draw-stop is called..which throws Uncaught TypeError: Cannot call method '_fireMouseEvent' of null from inside of L.Marker

https://github.com/snkashis/Leaflet.draw/tree/0.8_testing

@javashaman

We are seeing this issue for Android users running the Dolphin browser, after drawing a polyline twice.

@jczaplew

There is also an issue when editing polygons when using 0.8-dev. If you draw a polygon and then try and edit it you will get this error in line 10 of leaflet.draw.js: Uncaught TypeError: Cannot read property 'enable' of undefined.

It doesn't seem to be unique to a specific browser (tested in Chrome, Firefox, and Safari on OS X), and the error does not appear when using 0.7.2. I'll dig around a bit more and see what I can find.

@danzel
Owner

Another bug:
L.GeometryUtil.geodesicArea doesn't work any more.

Hoping to start on fixing these later today.

@danzel
Owner

Okay, there is a branch up now:
https://github.com/Leaflet/Leaflet.draw/tree/leaflet-master

Seems to work at least a bit :)

@danzel
Owner

If you create a polygon from geojson then try edit it, it'll fail.
See Leaflet/Leaflet#2618

Edit: I've done a horrible work around for this. If your polygon has nested areas we remove them. Will fix this properly when the above bug is fixed.

@rwwagner90

@danzel I got the code from https://github.com/Leaflet/Leaflet.draw/blob/leaflet-master/dist/leaflet.draw-src.js and it doesn't seem to help with polygons. I still get Uncaught TypeError: Cannot read property 'enable' of undefined. How do I fix this? What's the status on fully supporting 0.8-dev and Leaflet 1.0 when it's out?

@rwwagner90

I would be glad to help assist getting everything working with the new version of Leaflet, but I will definitely need some help to make sure I don't miss anything. Can everyone confirm they are still seeing these issues as well?

@danzel
Owner

You need to compress the js on that branch yourself. The build has not been updated.
Check it out and run jake.

@rwwagner90

@danzel I cloned the repo, and ran jake build, then took the resulting file and used it. It seems to fix some things, but not completely. I am able to edit shapes now, without any errors, but upon clicking save, the lines stay dashed, instead of going solid again. Here is a screenshot:

screenshot at nov 12 09-52-46

Also, editing polygons still doesn't work. With the following error:
Uncaught TypeError: Cannot read property 'enable' of undefined

Any ideas on fixing those two things?

@danzel
Owner

Does it work in the included debug page? I didn't run in to this, but maybe I didn't try it.

@rwwagner90

What debug page?

@rwwagner90

Those do not use the files from the dist folder do they? I just looked at the source on one, and it didn't appear to.

@danzel
Owner

They use the non built files.
You'll also need to replace the included leaflet with a built master version

@rwwagner90

I'll create my own test case then. Hold on.

@danzel
Owner

Cool.
Or if you can cause it in one of those that would be good.

@rwwagner90

I confirmed that I still get Uncaught TypeError: Cannot read property 'enable' of undefined using my built version of leaflet.draw and leaflet 0.8-dev. in your full.html example. I'm working on a plunker now, but I don't know how to upload the sprites, otherwise, it's working. Check it out. http://plnkr.co/edit/dwxdcmieSjnLBqqvADqh?p=preview

Draw a polygon, then try to edit it, you will get the error.

@danzel
Owner

Thanks, will check later.

@danzel
Owner

Your version of leaflet.draw is not built from the leaflet-master branch.
Check line 1148 of leaflet.draw-src.js in your plnkr
And compare to:
https://github.com/Leaflet/Leaflet.draw/blob/leaflet-master/src/edit/handler/Edit.Poly.js#L20
and
https://github.com/Leaflet/Leaflet.draw/blob/master/src/edit/handler/Edit.Poly.js#L20

I don't have the build stuff set up on this PC so I can't do a build for you.

@rwwagner90

I checked out the leaflet-master branch and ran jake build. Perhaps it didn't work and the dist files remained the same old ones. I'll try again.

@rwwagner90

I built again, and it works. Thanks for pointing that out for me! Are there any further outstanding issues with leaflet 0.8-dev?

@rwwagner90

@danzel I'm having an issue with selecting countries on my map. If I draw shapes, everything works with drawing, editing, and saving, but if I click a country, it outlines the country, and then when I click edit, I get Uncaught TypeError: Cannot read property 'lng' of null. Upon further investigation, it appears _latlng is null for the markers passed to _getMiddleLatLng, but _origLatLng appears to be populated correctly. Any idea why _origLatLng is populated and _latlng is not?

Seems to be an issue with _initMarkers perhaps, because after the marker is created there, it has _latlng = null. It being null doesn't seem to be the issue though. The issue is occurring in this code in leaflet:

L.Projection.LonLat = {
    project: function (latlng) {
        return new L.Point(latlng.lng, latlng.lat);
    },

latlng is null, and I'm not sure why or how to fix it. It works with the normal hand drawn shapes, so is there something I am missing with country select?

@danzel
Owner
@rwwagner90

@danzel
It does seem to be an issue with the nesting of polygons, I think. I just ran into another issue that I fixed by doing this:

var latLngs = Array.isArray(layer.getLatLngs()[0]) ? layer.getLatLngs()[0] : layer.getLatLngs();
        var points = latLngs.map(function (point) {
          return [point.lat, point.lng];
        });

So I am checking if the first element is also an array, and if it is, I grab that element, otherwise, I can just do getLatLngs() and it gives me what I need.

So it may be something similar with editing. Seems like the country outlines I am creating are nested polygons, and the polygons drawn with the Leaflet.draw tool, have been unnested, and only unnested things seem to work. This was a hack though right? Will nested work eventually? I'm not quite sure how to proceed.

@danzel
Owner

See #257 (comment)
and the issue it links.

@rwwagner90

Ah, so I won't be able to use GeoJSON until Leaflet fixes that issue? That comment appears to indicate that you implemented a workaround for it, but I still seem to be unable to edit. Should the workaround be working or is it expected that this would be broken for me?

@rwwagner90

@danzel should the workaround you implemented be working in this case?

@danzel
Owner

It wouldn't work for a real multi-polygon, but it should work for a polygon in geojson. No promises though and I'm not going to spend time fixing it until we resolve the leaflet issue around multi polygons

@rwwagner90

I understand. Is it something that will actually be fixed in Leaflet though or is Leaflet happy the way things are?

@danzel
Owner

Dunno, follow the leaflet bug while we discuss it

@cocomo

Just found this issue googling for an error i get from leaflet.draw 0.2.4-dev with leaflet 0.7.3. I'm trying to rewrite an existing polyline editor map to operate from geojson (we need additional information with the polyline). Does this error only come up with leaflets development version (0.8) or could it be also with the currently stable version?

@rwwagner90

@cocomo We did not have this issue using Leaflet 0.7.3. It was only after updating to 0.8-dev.

@cocomo

Thank you for the confirmation, of course it was my weird coding. I don't know if it helps with 0.8, but i was able the solve my error by adding the data into layers before adding it to the map:

L.geoJson(geoJsonData, {
    onEachFeature: function (feature, layer) {
        drawnItems.addLayer(layer);
    }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.