Leaflet.draw error adding L.Control.Draw

1,707 views
Skip to first unread message

Luís Miguel Royo Pérez

unread,
Nov 23, 2016, 4:01:32 AM11/23/16
to Leaflet
Hi everyone,

I'm facing problems with this plugin. I can not even add a toolbar. This is what I'm doing:

In index.html file I'm using this lines:

After, in the script file I'm using these lines to add the controls:


var drawnItems = new L.FeatureGroup(suc,crs);
map.addLayer(drawnItems);
var drawControl = new L.Control.Draw({
         edit: {
             featureGroup: drawnItems
         }
     });
     map.addControl(drawControl);


And I get this error:


TypeError: L.Control.Draw is not a constructor
http://xxxx.com/xxxxx/js/map.js Line 34


I've been searching in forums, the docs, and in several related pages but I haven't found any clue about what's happening. Could anyone help me in this??


If you need more information about it, just tell and I would be pleased to add it.


Thanks per advance!!

Matt Travis

unread,
Nov 24, 2016, 2:45:29 AM11/24/16
to Leaflet
Works for me: http://all-mapped-out.co.uk/simple.html

What's in map.js? Does that need to reference the leaflet and draw library to work properly?

Matt

Luís Miguel Royo Pérez

unread,
Nov 24, 2016, 2:54:29 AM11/24/16
to Leaflet
You're right,

is working fine, I solved this situation, it was just a matter of situation of this line:

I sited it in the body tag, when I should do it in the head tag. That's all!

Thanks for the reply!!

Reply all
Reply to author
Forward
0 new messages