2021-07-06 19:06:39 +00:00
|
|
|
(function () {
|
|
|
|
let mapEl = document.getElementById('map')
|
|
|
|
let locations = JSON.parse(mapEl.dataset.locations)
|
|
|
|
|
|
|
|
let map = L.map('map')
|
|
|
|
|
2021-07-19 16:41:38 +00:00
|
|
|
L.tileLayer(mapEl.dataset.tiles, {
|
2021-07-06 19:06:39 +00:00
|
|
|
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
|
|
|
}).addTo(map)
|
|
|
|
|
|
|
|
let markers = []
|
|
|
|
locations.forEach(loc => {
|
|
|
|
let marker = [loc.Lat, loc.Lon]
|
|
|
|
L.marker(marker).addTo(map).on('click', function () {
|
|
|
|
window.open(loc.Post, '_blank').focus()
|
|
|
|
})
|
|
|
|
markers.push(marker)
|
|
|
|
})
|
|
|
|
|
|
|
|
map.fitBounds(markers)
|
|
|
|
map.zoomOut(2, { animate: false })
|
|
|
|
})()
|