forked from linghuam/Leaflet.TrackPlayBack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
50 lines (44 loc) · 1.87 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
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>leaflet.trackplayback</title>
<link rel="stylesheet" href="examples/lib/leaflet/leaflet.css">
<link rel="stylesheet" href="dist/control.playback.css">
<script src="examples/lib/leaflet/leaflet.js"></script>
<script src="dist/control.trackplayback.js"></script>
<script src="dist/leaflet.trackplayback.js"></script>
</head>
<body>
<a href="https://github.com/linghuam/Leaflet.TrackPlayBack"><img style="position: absolute; top: 0; left: 0; border: 0;z-index: 999;"
src="https://s3.amazonaws.com/github/ribbons/forkme_left_green_007200.png" alt="Fork me on GitHub"></a>
<div id='mapid' style=" position: absolute; left: 0; top: 0; right: 0; bottom: 0; width: 100%; height: 100%; overflow: hidden;"></div>
<script>
// create map and add baseLayer
const map = L.map('mapid').setView([34.36384353883067, 134.09362792968753], 9);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
// get data from server
const xhr = new XMLHttpRequest();
xhr.open('GET', 'examples/data/test.json', true);
xhr.onreadystatechange = xhrCallback;
xhr.send();
function xhrCallback() {
if (xhr.readyState === 4 && xhr.status === 200) {
const data = JSON.parse(xhr.responseText);
const trackplayback = L.trackplayback(data, map, {
targetOptions: {
useImg: true,
imgUrl: 'examples/ship.png'
}
});
const trackplaybackControl = L.trackplaybackcontrol(trackplayback);
trackplaybackControl.addTo(map);
}
}
</script>
</body>
</html>