Upgrades maplibre-gl to v6.10.0 and modernizes script loading
This commit is contained in:
1 parent
c6c3075c5c
commit
177b70631b
7 files changed
+914
-101
No files matched your search
@@ -0,0 +1,30 @@
|
||||
import * as maplibregl from '../vendor/maplibre-gl/maplibre-gl.mjs';
|
||||
|
||||
document.querySelectorAll('.openfreemap').forEach((container) => {
|
||||
const center = [
|
||||
parseFloat(container.dataset.lon),
|
||||
parseFloat(container.dataset.lat)
|
||||
];
|
||||
const zoom = parseFloat(container.dataset.zoom);
|
||||
const map = new maplibregl.Map({
|
||||
style: container.dataset.style,
|
||||
center: center,
|
||||
zoom: zoom,
|
||||
container: container
|
||||
});
|
||||
const marker = new maplibregl.Marker({
|
||||
color: container.dataset.color
|
||||
})
|
||||
.setLngLat(center)
|
||||
.addTo(map);
|
||||
const popupText = container.dataset.popup;
|
||||
if (popupText) {
|
||||
const popup = new maplibregl.Popup({
|
||||
closeOnClick: false
|
||||
}).setHTML(popupText);
|
||||
marker.setPopup(popup);
|
||||
marker.togglePopup();
|
||||
}
|
||||
map.addControl(new maplibregl.NavigationControl());
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user