-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.html
56 lines (54 loc) · 1.94 KB
/
index.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
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>
<html>
<head>
<title>Polygon Drag</title>
<script type="text/javascript" src="./leaflet/leaflet-src.js"></script>
<link rel='stylesheet' href='./leaflet/leaflet.css' />
<script type="text/javascript" src="./leaflet.polydrag.js"></script>
</head>
<body>
<div id="map" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></div>
<script type="text/javascript">
var tileUrl = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png';
var tileLayer = new L.TileLayer(tileUrl, {maxZoom: 18});
var map = new L.Map(
'map',
{
layers: [tileLayer],
center: new L.LatLng(-38.2772, 175.7756),
zoom: 8
}
);
var pg = new L.Polygon(
[
[-37.7772, 175.2756], [-38.7772, 175.2756],
[-38.7772, 176.2756]
]
);
pg.dragging = new L.Handler.PolyDrag(pg);
map.addLayer(pg);
pg.dragging.enable();
pg.on('dragend', function () {
console.log(pg.getLatLngs());
});
var pl = new L.Polyline(
[
[-38.62545397209084, 175.9625244140625],
[-39.02345139405933, 176.3690185546875]
]
);
pl.dragging = new L.Handler.PolyDrag(pl);
map.addLayer(pl);
pl.dragging.enable();
pl.on('dragend', function () {
console.log(pl.getLatLngs());
});
var m = new L.Marker([-38.2772, 175.7756]);
map.addLayer(m);
m.dragging.enable();
m.on('dragend', function () {
console.log(m.getLatLng());
});
</script>
</body>
</html>