mirror of https://github.com/jlelse/GoBlog
18 lines
565 B
JavaScript
18 lines
565 B
JavaScript
(function () {
|
|
let mapEl = document.getElementById('map')
|
|
let paths = JSON.parse(mapEl.dataset.paths)
|
|
|
|
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 polylines = []
|
|
|
|
paths.forEach(path => {
|
|
polylines.push(L.polyline(path.map(point => [point.Lat, point.Lon]), { color: 'blue' }).addTo(map))
|
|
})
|
|
|
|
map.fitBounds(L.featureGroup(polylines).getBounds(), { padding: [5, 5] })
|
|
})() |