Answer the question
In order to leave comments, you need to log in
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: '© <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>
<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>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question