TransWikia.com

Leaflet Draw Error

Geographic Information Systems Asked by Mauro Tello on January 14, 2021

I’m trying to incorporate Leaflet. Draw on my map but I get the following error
I’m using version 1.7.1

Draw.Polyline.js:55 Uncaught TypeError: Cannot read property 'draw' of undefined
    at initialize (Draw.Polyline.js:55)
    at new i (Class.js:22)
    at i.getModeHandlers (DrawToolbar.js:41)
    at i.addToolbar (Toolbar.js:89)
    at i.onAdd (Control.Draw.js:58)
    at i.addTo (Control.js:70)
    at i.addControl (Control.js:137)
    at maps:420

code

var mymap = L.map( 'map', {
            center: [-40.7972547, -62.9672901],
            minZoom: 2,
            zoom: 17,
            fadeAnimation: false,
            zoomAnimation: false,
            markerZoomAnimation: false
        });


        var base = L.tileLayer( 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
            attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',
            subdomains: ['a','b','c']
        }).addTo( mymap ); 

        var myIcon = L.icon({
           iconUrl: '{{ asset("img/icon.png") }}',
        });

        var puntos = L.layerGroup();
        puntos.addTo(mymap);





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

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP