-
Notifications
You must be signed in to change notification settings - Fork 1
/
editor.html
47 lines (41 loc) · 1.44 KB
/
editor.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Leaflet Draw</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox.js/v2.1.3/mapbox.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox.js/v2.1.3/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<body>
<link href='https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-draw/v0.2.2/leaflet.draw.css' rel='stylesheet' />
<script src='https://api.tiles.mapbox.com/mapbox.js/plugins/leaflet-draw/v0.2.2/leaflet.draw.js'></script>
<div id='map'></div>
<script>
L.mapbox.accessToken = 'pk.eyJ1IjoidGR1cmFuZCIsImEiOiI0T1ZEWlRVIn0.1PEGeiEWz6RUBfZq9Bvy7Q';
var map = L.mapbox.map('map', 'examples.map-i86nkdio')
.setView([6.2517228252549435, -75.5689188838005], 17);
var featureGroup = L.featureGroup().addTo(map);
var drawControl = new L.Control.Draw({
edit: {
featureGroup: featureGroup
}
}).addTo(map);
map.on('draw:created', function(e) {
featureGroup.addLayer(e.layer);
//JSON.stringify(e.layer.toGeoJSON().geometry.coordinates)
});
featureGroup.on("click",function(e) {
// console.log(e);
var popup = L.popup()
.setLatLng(e.latlng)
.setContent(JSON.stringify(e.layer.toGeoJSON().geometry.coordinates))
.openOn(map);
})
</script>
</body>
</html>