UNPKG

@trailstash/ultra

Version:

A web based tool for making MapLibre GL maps with data from sources such as Overpass, GeoJSON, GPX, KML, TCX, etc

67 lines (57 loc) 2.73 kB
import DOMPurify from "dompurify"; import { Protocol } from "pmtiles"; import { addProtocol, setRTLTextPlugin, setWorkerUrl } from "maplibre-gl"; import { normalizeCSS } from "./lib/normalize.js"; import MapLibre from "./components/maplibre.js"; import { HTMLControl } from "./components/html-control.js"; import { UltraLoader } from "./components/ultra-loader.js"; import { UltraMap } from "./components/ultra-map.js"; import { UltraApp } from "./components/ultra-app.js"; import { UltraIDE } from "./components/ultra-ide.js"; import { CodeEditor } from "./components/code-editor.js"; import { NavBar } from "./components/nav-bar.js"; import { RunButton } from "./components/run-button.js"; import { ExportModal as DownloadButton } from "./components/export-modal.js"; import { StylePicker } from "./components/style-picker.js"; import { ShareModal as ShareButton } from "./components/share-modal.js"; import { HelpModal } from "./components/help-modal.js"; import { FSButton } from "./components/fs-button.js"; import { FontAwesomeIcon } from "./components/fontawesome-icon.js"; import { ButtonModal } from "./components/button-modal.js"; import { MapPopup } from "./components/map-popup.js"; // Allow pages in new windows securely DOMPurify.addHook("afterSanitizeAttributes", function (node) { // set all elements owning target to target=_blank if ("target" in node) { node.setAttribute("target", "_blank"); node.setAttribute("rel", "noopener"); } }); // style document.adoptedStyleSheets.push(normalizeCSS); // maplibre worker setWorkerUrl(new URL("./maplibre-gl-worker.mjs", import.meta.url).toString()); // maplibre plugins const protocol = new Protocol(); addProtocol("pmtiles", protocol.tile); setRTLTextPlugin("./mapbox-gl-rtl-text@0.2.3.js", true); // register element customElements.define("code-editor", CodeEditor); customElements.define("map-libre", MapLibre); customElements.define("nav-bar", NavBar); customElements.define("run-button", RunButton); customElements.define("download-button", DownloadButton); customElements.define("share-button", ShareButton); customElements.define("help-modal", HelpModal); customElements.define("style-picker", StylePicker); customElements.define("fs-button", FSButton); customElements.define("fa-icon", FontAwesomeIcon); customElements.define("button-modal", ButtonModal); customElements.define("map-popup", MapPopup); customElements.define("html-control", HTMLControl); customElements.define("ultra-map", UltraMap); customElements.define("ultra-ide", UltraIDE); customElements.define("ultra-app", UltraApp); customElements.define("ultra-loader", UltraLoader); // reload on hash changes addEventListener("hashchange", () => window.location.reload());