B
B
beduin012016-07-24 17:56:21
leaflet
beduin01, 2016-07-24 17:56:21

How to run Leaflet.draw example?

https://github.com/Leaflet/Leaflet.draw
_ there should be no errors.
As a result, an error comes out: `L.Control.Draw is not a constructor` here is my code:

var map = L.map('map').setView([51.505, -0.09], 13);

// add an OpenStreetMap tile layer
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
    attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);

// Initialise the FeatureGroup to store editable layers
var drawnItems = new L.FeatureGroup();
map.addLayer(drawnItems);

// Initialise the draw control and pass it the FeatureGroup of editable layers
var drawControl = new L.Control.Draw({
    edit: {
        featureGroup: drawnItems
    }
});
map.addControl(drawControl);

html:
<html>
<head>

<style>
  #map { height: 90vh; }
</style>

 <link rel="stylesheet" href="https://npmcdn.com/[email protected]/dist/leaflet.css" />
 <link rel="stylesheet" href="js/leaflet.draw.css" />

</head>
  <body>

     <div id="map"></div>

  </body>

<script src="js/leaflet.js"></script>
<script src="js/mymap.js"></script>

<script src="js/leaflet.draw.js"></script>
<script src="js/leaflet.draw-src.js"></script>


</html>

What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
My joy, 2016-07-24
@beduin01

can mymap.js be lower than leaflet.draw.js ?
and another option is to remove leaflet.draw-src.js, because leaflet.draw.js is enough

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question