2021-07-06 19:06:39 +00:00
|
|
|
(function () {
|
|
|
|
let mapEl = document.getElementById('map')
|
2021-11-13 19:40:25 +00:00
|
|
|
let locations = (mapEl.dataset.locations == "") ? [] : JSON.parse(mapEl.dataset.locations)
|
|
|
|
let tracks = (mapEl.dataset.tracks == "") ? [] : JSON.parse(mapEl.dataset.tracks)
|
2021-07-06 19:06:39 +00:00
|
|
|
|
|
|
|
let map = L.map('map')
|
|
|
|
|
2021-11-10 10:13:30 +00:00
|
|
|
L.tileLayer("/x/tiles/{z}/{x}/{y}.png", {
|
2021-07-06 19:06:39 +00:00
|
|
|
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-07-06 19:06:39 +00:00
|
|
|
locations.forEach(loc => {
|
2021-11-16 17:01:11 +00:00
|
|
|
features.push(L.marker([loc.Lat, loc.Lon]).addTo(map).on('click', function () {
|
2021-07-06 19:06:39 +00:00
|
|
|
window.open(loc.Post, '_blank').focus()
|
2021-11-13 19:19:46 +00:00
|
|
|
}))
|
|
|
|
})
|
|
|
|
|
|
|
|
tracks.forEach(track => {
|
|
|
|
track.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).on('click', function () {
|
|
|
|
window.open(track.Post, '_blank').focus()
|
|
|
|
}))
|
|
|
|
})
|
|
|
|
track.Points.forEach(point => {
|
|
|
|
features.push(L.marker([point.Lat, point.Lon]).addTo(map).on('click', function () {
|
2021-11-13 19:19:46 +00:00
|
|
|
window.open(track.Post, '_blank').focus()
|
|
|
|
}))
|
2021-07-06 19:06:39 +00:00
|
|
|
})
|
|
|
|
})
|
2021-11-13 19:19:46 +00:00
|
|
|
|
2021-11-16 17:01:11 +00:00
|
|
|
map.fitBounds(L.featureGroup(features).getBounds(), { padding: [5, 5] })
|
2021-07-06 19:06:39 +00:00
|
|
|
})()
|