mirror of https://github.com/jlelse/GoBlog
20 lines
628 B
JavaScript
20 lines
628 B
JavaScript
(function () {
|
|
let mapEl = document.getElementById('map')
|
|
let locations = JSON.parse(mapEl.dataset.locations)
|
|
|
|
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)
|
|
|
|
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, { padding: [5, 5] })
|
|
})() |