Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions assets/js/leaflet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
(() => {
const script = document.currentScript;
const mapId = script?.getAttribute("data-map-id");

const mapCenterX = script?.getAttribute("data-map-center-x");
const mapCenterY = script?.getAttribute("data-map-center-y");
const defaultZoom = script?.getAttribute("data-default-zoom");

const tileBaseURL = script?.getAttribute("data-tile-base-url");
const minZoom = script?.getAttribute("data-min-zoom");
const maxZoom = script?.getAttribute("data-max-zoom");
const copyrightURL = script?.getAttribute("data-copyright-url");
const copyrightName = script?.getAttribute("data-copyright-name");

const markerIconURL = script?.getAttribute("data-marker-icon-url");
const markerIconRetinaURL = script?.getAttribute("data-marker-icon-retina-url");
const markerIconShadowURL = script?.getAttribute("data-marker-icon-shadow-url");

const markerX = script?.getAttribute("data-marker-x");
const markerY = script?.getAttribute("data-marker-y");
const markerTooltip = script?.getAttribute("data-marker-tooltip");

const mapHeight = script?.getAttribute("data-map-height");
const mapWidth = script?.getAttribute("data-map-width");

const mapElement = document.getElementById(mapId);
mapElement.style.maxHeight = "100vh";
mapElement.style.height = mapHeight;
mapElement.style.maxWidth = "80vw";
mapElement.style.width = mapWidth;

const map = L.map(mapId).setView([mapCenterX, mapCenterY], defaultZoom);

L.tileLayer(`${tileBaseURL}/{z}/{x}/{y}.png`, {
minZoom: minZoom,
maxZoom: maxZoom,
attribution: `&copy; <a href="${copyrightURL}">${copyrightName}</a>`,
className: "nozoom",
}).addTo(map);

if (markerX && markerY) {
const markerIcon = L.icon({
iconUrl: markerIconURL,
iconRetinaUrl: markerIconRetinaURL,
shadowUrl: markerIconShadowURL,
className: "nozoom",
});
const marker = L.marker([markerX, markerY], { icon: markerIcon }).addTo(map);
markerTooltip && marker.bindTooltip(`<p>${markerTooltip}</p>`);
}
})();
26 changes: 26 additions & 0 deletions assets/lib/leaflet/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
BSD 2-Clause License

Copyright (c) 2010-2023, Volodymyr Agafonkin
Copyright (c) 2010-2011, CloudMade
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Binary file added assets/lib/leaflet/images/marker-icon-2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/lib/leaflet/images/marker-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/lib/leaflet/images/marker-shadow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading