2021-11-10 10:13:30 +00:00
|
|
|
(function () {
|
|
|
|
let mapEl = document.getElementById('map')
|
2021-11-16 17:01:11 +00:00
|
|
|
let paths = (mapEl.dataset.paths == "") ? [] : JSON.parse(mapEl.dataset.paths)
|
|
|
|
let points = (mapEl.dataset.points == "") ? [] : JSON.parse(mapEl.dataset.points)
|
2021-11-10 10:13:30 +00:00
|
|
|
|
|
|
|
let map = L.map('map')
|
|
|
|
|
|
|
|
L.tileLayer("/x/tiles/{z}/{x}/{y}.png", {
|
|
|
|
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
|
|
|
}).addTo(map)
|
|
|
|
|
2021-11-16 17:01:11 +00:00
|
|
|
let features = []
|
2021-11-13 19:19:46 +00:00
|
|
|
|
2021-11-10 10:13:30 +00:00
|
|
|
paths.forEach(path => {
|
2021-11-16 17:01:11 +00:00
|
|
|
features.push(L.polyline(path.map(point => [point.Lat, point.Lon]), { color: 'blue' }).addTo(map))
|
2021-11-10 10:13:30 +00:00
|
|
|
})
|
2021-11-13 19:19:46 +00:00
|
|
|
|
2021-11-16 17:01:11 +00:00
|
|
|
points.forEach(point => {
|
|
|
|
features.push(L.marker([point.Lat, point.Lon]).addTo(map))
|
|
|
|
})
|
|
|
|
|
|
|
|
map.fitBounds(L.featureGroup(features).getBounds(), { padding: [5, 5] })
|
2021-11-10 10:13:30 +00:00
|
|
|
})()
|