Leaflet / Leaflet.draw

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

Uncaught TypeError: this.callInitHooks is not a function #934

Closed DrPDash closed 5 years ago

DrPDash commented 5 years ago

How to reproduce

What behaviour I'm expecting and which behaviour I'm seeing

Expecting to see as in: http://leaflet.github.io/Leaflet.draw/docs/examples/full.html Getting error (in Chrome console):

            Uncaught TypeError: this.callInitHooks is not a function
            at Function.e [as Draw] (leaflet.js:5)
            at HTMLDocument.<anonymous>

            at l (jquery-3.3.1.min.js:2)
            at c (jquery-3.3.1.min.js:2)

Minimal example reproducing the issue

I am replicating the example given at: http://leaflet.github.io/Leaflet.draw/docs/examples/full.html

The simplest code looks like: // Draw Tools

            var drawnItems = new L.FeatureGroup();
            map.addLayer(drawnItems);
            ctlDraw = L.Control.Draw({
                edit: {
                    featureGroup: drawnItems,
                    poly: {
                        allowIntersection: false
                    }
                },
                position: 'topright',
                draw: {
                    polygon: {
                        allowIntersection: false,
                        showArea: true
                    }
                }
            }).addTo(map);

            map.on(L.Draw.Event.CREATED, function (event) {
                var layer = event.layer;
                drawnItems.addLayer(layer);
            });

Using jsfiddle or another example site.

DrPDash commented 5 years ago

After a thorough search over the internet, it seems like there are different versions here and on CDN and following some examples, this was resolved, i.e., it works now. I am closing the request. Thanks

JavaScript1 commented 5 years ago

请问您是如何解决掉这个问题的

shayneoneill commented 4 years ago

Was a solution ever found, or is this a "wont fix"?.

Also please don't ask a question, declare you found an answer without saying what it is, and closing it. Thats just bad manners.

DrPDash commented 4 years ago

This has been so long that I don't recall the issue right away. But the 'jsfiddle' link on my prev comment shows a working example. And, whatever the issue was, just sourcing from one of the several CDNs solved the issue. So, @shayneoneill if you need some assistance in this friendly shared resource community, please request instead of policing - this is bad manners. One cannot wake up after 10 months and preach. Thanks