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
|
|
|
|
2021-11-22 15:36:17 +00:00
|
|
|
let map = L.map('map', {
|
|
|
|
minZoom: mapEl.dataset.minzoom,
|
|
|
|
maxZoom: mapEl.dataset.maxzoom
|
|
|
|
})
|
2021-07-06 19:06:39 +00:00
|
|
|
|
2021-12-12 10:03:14 +00:00
|
|
|
L.tileLayer("/-/tiles/{s}/{z}/{x}/{y}.png", {
|
2021-11-22 15:36:17 +00:00
|
|
|
attribution: mapEl.dataset.attribution,
|
2021-07-06 19:06:39 +00:00
|
|
|
}).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
|
|
|
})()
|