-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
46 lines (39 loc) · 2.24 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Demo of Leaflet.PolylineMeasure [metric]</title>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<link rel="stylesheet" href="Leaflet.PolylineMeasure.css" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<script src="Leaflet.PolylineMeasure.js"></script>
<style>
body {padding: 0; margin: 0;}
html, body, #map {height: 100%;}
</style>
</head>
<body>
<div id="map"></div>
<script>
var layerOsm = new L.TileLayer('https://{s}.api.mapbox.com/v4/mapbox.outdoors/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoicHBldGUiLCJhIjoiY2lsdmE2ZmQ2MDA4OHZxbTZpcmx1emtqbSJ9.Two7SPSaIZysqgOTrrLkRg', {
subdomains: 'ab', maxZoom: 20, noWrap:true, attribution:'<a href="http://www.mapbox.com">Mapbox</a> | <a href="http://www.openstreetmap.org/copyright/">OpenStreetMap</a>' });
var map = new L.Map('map').addLayer(layerOsm).setView(new L.LatLng(47.8, 13.0), 4);
L.control.scale({maxWidth:240, metric:true, imperial:false, position: 'bottomleft'}).addTo(map);
var control = L.control.polylineMeasure({position:'topleft', imperial:true, clearMeasurementsOnStop: false, showMeasurementsClearControl: true}).addTo(map);
control.on("enable", function () {console.log("Measuring is enable");});
control.on("disable", function () {console.log("Measuring is disable");});
control.on("toggle", function (data) {console.log("Measuring is toggle " + (data.status ? "on" : "off"));});
control.on("start", function () {console.log("Measuring is started");});
// control.on("move", function (data) {
// console.log("Path length is " + data.length + ", all distance is " + data.distance);
// });
control.on("path", function (data) {
console.log("Path length is " + data.length + ", all distance is " + data.distance);
});
control.on("stop", function (data) {
console.log("Measuring is stopped with distance: " + data.distance);
});
</script>
</body>
</html>