File size: 1,616 Bytes
3bc64f7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!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="./lib/leaflet/leaflet.css">
  <link rel="stylesheet" href="../dist/control.playback.css">
  <script src="./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;" 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>
    const xhr = new XMLHttpRequest();
    xhr.open('GET', './data/test.json', false);
    xhr.send(null);
    const data = JSON.parse(xhr.responseText);
    const map = L.map('mapid').setView([33.74, 134.38], 6);
    L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
      attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
    }).addTo(map);

    const trackplayback = L.trackplayback(data, map, {
      targetOptions: {
        useImg: true,
        imgUrl: './ship.png'
      }
    });
    const trackplaybackControl = L.trackplaybackcontrol(trackplayback);
    trackplaybackControl.addTo(map);

  </script>
</body>

</html>