Skip to content

Instantly share code, notes, and snippets.

@mgottholsen
Created October 31, 2017 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgottholsen/5b2079a49562120af7b650abde9e0ab6 to your computer and use it in GitHub Desktop.
Save mgottholsen/5b2079a49562120af7b650abde9e0ab6 to your computer and use it in GitHub Desktop.
Leaflet Draw
<div id="map_id" class="maps"></div>
var map = L.map('map_id').setView([38.2527, -85.764771], 14);
L.tileLayer('http://tile.stamen.com/toner-lite/{z}/{x}/{y}.png').addTo(map);
var edLayer = L.featureGroup().addTo(map);
var drawCtrl = new L.Control.Draw({
draw: {
polygon: false,
marker: false
},
edit: {
featureGroup: edLayer
}
});
map.addControl(drawCtrl);
map.on('draw:created', function (e) {
edLayer.addLayer(e.layer);
});
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
<script src="https://xguaita.github.io/mtig-js/libs/draw/leaflet.draw.js"></script>
body {
margin:0;
padding:0;
}
.maps {
width: 1080px;
height: 768px;
}
<link href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" rel="stylesheet" />
<link href="https://xguaita.github.io/mtig-js/libs/draw/leaflet.draw.css" rel="stylesheet" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment