@prushforth/map 1.0.0-preview.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +89 -0
- package/demo/index.html +78 -0
- package/dist/cjs/AttributionButton-DgbgLHy4.js +106 -0
- package/dist/cjs/MapTileLayer-D4vp8bR4.js +454 -0
- package/dist/cjs/app-globals-DY--Q2Nl.js +775 -0
- package/dist/cjs/calculatePosition-CDcdNl7C.js +92 -0
- package/dist/cjs/gcds-ext-map.cjs.js +47 -0
- package/dist/cjs/gcds-ext-map_2.cjs.entry.js +8081 -0
- package/dist/cjs/index-CW_WOSnc.js +32697 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/loader.cjs.js +14 -0
- package/dist/cjs/locale-_4nEyxeO.js +153 -0
- package/dist/cjs/map-a.cjs.entry.js +16 -0
- package/dist/cjs/map-caption.cjs.entry.js +55 -0
- package/dist/cjs/map-extent.cjs.entry.js +993 -0
- package/dist/cjs/map-feature.cjs.entry.js +636 -0
- package/dist/cjs/map-featurecaption.cjs.entry.js +14 -0
- package/dist/cjs/map-geometry.cjs.entry.js +36 -0
- package/dist/cjs/map-input.cjs.entry.js +348 -0
- package/dist/cjs/map-link.cjs.entry.js +6055 -0
- package/dist/cjs/map-meta.cjs.entry.js +40 -0
- package/dist/cjs/map-properties.cjs.entry.js +14 -0
- package/dist/cjs/map-select.cjs.entry.js +100 -0
- package/dist/cjs/map-span.cjs.entry.js +14 -0
- package/dist/cjs/map-style.cjs.entry.js +127 -0
- package/dist/cjs/map-tile.cjs.entry.js +274 -0
- package/dist/cjs/renderStyles-yOMXvf12.js +59 -0
- package/dist/collection/assets/canada.json +1 -0
- package/dist/collection/assets/images/w3community.ico +0 -0
- package/dist/collection/assets/mapml/en/apstile/arctic +18 -0
- package/dist/collection/assets/mapml/en/cbmtile/canvec +22 -0
- package/dist/collection/assets/mapml/en/cbmtile/cbmt +24 -0
- package/dist/collection/assets/mapml/en/cbmtile/cbmtgeom +20 -0
- package/dist/collection/assets/mapml/en/cbmtile/cbmtsimple +20 -0
- package/dist/collection/assets/mapml/en/cbmtile/current_conditions +33 -0
- package/dist/collection/assets/mapml/en/cbmtile/toporama +25 -0
- package/dist/collection/assets/mapml/en/custom/arcticsdi.mapml +18 -0
- package/dist/collection/assets/mapml/en/osmtile/cbmt +24 -0
- package/dist/collection/assets/mapml/en/osmtile/current_conditions +32 -0
- package/dist/collection/assets/mapml/en/osmtile/dark.mapml +19 -0
- package/dist/collection/assets/mapml/en/osmtile/light.mapml +19 -0
- package/dist/collection/assets/mapml/en/osmtile/osm +19 -0
- package/dist/collection/assets/mapml/en/osmtile/toporama +25 -0
- package/dist/collection/assets/mapml/fr/apstile/arctic +19 -0
- package/dist/collection/assets/mapml/fr/cbmtile/canvec +22 -0
- package/dist/collection/assets/mapml/fr/cbmtile/cbmt +24 -0
- package/dist/collection/assets/mapml/fr/cbmtile/cbmtgeom +20 -0
- package/dist/collection/assets/mapml/fr/cbmtile/cbmtsimple +20 -0
- package/dist/collection/assets/mapml/fr/cbmtile/current_conditions +25 -0
- package/dist/collection/assets/mapml/fr/cbmtile/toporama +25 -0
- package/dist/collection/assets/mapml/fr/osmtile/cbmt +24 -0
- package/dist/collection/assets/mapml/fr/osmtile/current_conditions +24 -0
- package/dist/collection/assets/mapml/fr/osmtile/dark.mapml +19 -0
- package/dist/collection/assets/mapml/fr/osmtile/light.mapml +19 -0
- package/dist/collection/assets/mapml/fr/osmtile/osm +19 -0
- package/dist/collection/assets/mapml/fr/osmtile/toporama +25 -0
- package/dist/collection/assets/pmtiles/darkTheme.js +19 -0
- package/dist/collection/assets/pmtiles/lightTheme.js +19 -0
- package/dist/collection/collection-manifest.json +28 -0
- package/dist/collection/components/gcds-ext-map/assets/pmtiles/darkTheme.js +19 -0
- package/dist/collection/components/gcds-ext-map/assets/pmtiles/lightTheme.js +19 -0
- package/dist/collection/components/gcds-ext-map/gcds-ext-map.css +2138 -0
- package/dist/collection/components/gcds-ext-map/gcds-ext-map.js +1517 -0
- package/dist/collection/components/gcds-ext-map/stories/gcds-ext-map.stories.js +367 -0
- package/dist/collection/components/map-a/map-a.js +89 -0
- package/dist/collection/components/map-caption/map-caption.js +52 -0
- package/dist/collection/components/map-extent/map-extent.js +809 -0
- package/dist/collection/components/map-feature/map-feature.js +724 -0
- package/dist/collection/components/map-featurecaption/map-featurecaption.js +6 -0
- package/dist/collection/components/map-geometry/map-geometry.js +57 -0
- package/dist/collection/components/map-input/map-input.js +355 -0
- package/dist/collection/components/map-layer/map-layer.js +1245 -0
- package/dist/collection/components/map-layer/stories/map-layer.stories.js +101 -0
- package/dist/collection/components/map-link/map-link.js +1149 -0
- package/dist/collection/components/map-meta/map-meta.js +82 -0
- package/dist/collection/components/map-properties/map-properties.js +7 -0
- package/dist/collection/components/map-select/map-select.js +145 -0
- package/dist/collection/components/map-span/map-span.js +7 -0
- package/dist/collection/components/map-style/map-style.js +144 -0
- package/dist/collection/components/map-tile/map-tile.js +370 -0
- package/dist/collection/components/utils/mapml/DOMTokenList.js +123 -0
- package/dist/collection/components/utils/mapml/DefaultMapOptions.js +11 -0
- package/dist/collection/components/utils/mapml/Util.js +1601 -0
- package/dist/collection/components/utils/mapml/control/AttributionButton.js +101 -0
- package/dist/collection/components/utils/mapml/control/FullscreenButton.js +181 -0
- package/dist/collection/components/utils/mapml/control/GeolocationButton.js +70 -0
- package/dist/collection/components/utils/mapml/control/LayerControl.js +212 -0
- package/dist/collection/components/utils/mapml/control/ReloadButton.js +75 -0
- package/dist/collection/components/utils/mapml/control/ScaleBar.js +108 -0
- package/dist/collection/components/utils/mapml/control/SearchButton.js +565 -0
- package/dist/collection/components/utils/mapml/elementSupport/extents/createLayerControlForExtent.js +259 -0
- package/dist/collection/components/utils/mapml/elementSupport/inputs/heightInput.js +18 -0
- package/dist/collection/components/utils/mapml/elementSupport/inputs/hiddenInput.js +19 -0
- package/dist/collection/components/utils/mapml/elementSupport/inputs/locationInput.js +127 -0
- package/dist/collection/components/utils/mapml/elementSupport/inputs/widthInput.js +18 -0
- package/dist/collection/components/utils/mapml/elementSupport/inputs/zoomInput.js +30 -0
- package/dist/collection/components/utils/mapml/elementSupport/layers/calculatePosition.js +88 -0
- package/dist/collection/components/utils/mapml/elementSupport/layers/createLayerControlForLayer.js +326 -0
- package/dist/collection/components/utils/mapml/elementSupport/layers/renderStyles.js +55 -0
- package/dist/collection/components/utils/mapml/elementSupport/viewers/matchMedia.js +251 -0
- package/dist/collection/components/utils/mapml/features/featureRenderer.js +342 -0
- package/dist/collection/components/utils/mapml/features/geometry.js +268 -0
- package/dist/collection/components/utils/mapml/features/path.js +485 -0
- package/dist/collection/components/utils/mapml/handlers/AnnounceMovement.js +154 -0
- package/dist/collection/components/utils/mapml/handlers/ContextMenu.js +1436 -0
- package/dist/collection/components/utils/mapml/handlers/FeatureIndex.js +116 -0
- package/dist/collection/components/utils/mapml/handlers/QueryHandler.js +476 -0
- package/dist/collection/components/utils/mapml/handlers/keyboard.js +60 -0
- package/dist/collection/components/utils/mapml/layers/Crosshair.js +108 -0
- package/dist/collection/components/utils/mapml/layers/DebugOverlay.js +357 -0
- package/dist/collection/components/utils/mapml/layers/FeatureIndexOverlay.js +239 -0
- package/dist/collection/components/utils/mapml/layers/ImageLayer.js +136 -0
- package/dist/collection/components/utils/mapml/layers/MapExtentLayer.js +114 -0
- package/dist/collection/components/utils/mapml/layers/MapFeatureLayer.js +623 -0
- package/dist/collection/components/utils/mapml/layers/MapLayer.js +640 -0
- package/dist/collection/components/utils/mapml/layers/MapTileLayer.js +450 -0
- package/dist/collection/components/utils/mapml/layers/TemplatedFeaturesOrTilesLayer.js +346 -0
- package/dist/collection/components/utils/mapml/layers/TemplatedImageLayer.js +276 -0
- package/dist/collection/components/utils/mapml/layers/TemplatedPMTilesLayer.js +135 -0
- package/dist/collection/components/utils/mapml/layers/TemplatedTileLayer.js +664 -0
- package/dist/collection/components/utils/utils.js +26 -0
- package/dist/collection/fonts/icons/LICENSE.txt +92 -0
- package/dist/collection/fonts/icons/README.md +543 -0
- package/dist/collection/fonts/icons/gcds-icons.css +110 -0
- package/dist/collection/fonts/icons/gcds-icons.eot +0 -0
- package/dist/collection/fonts/icons/gcds-icons.svg +82 -0
- package/dist/collection/fonts/icons/gcds-icons.ttf +0 -0
- package/dist/collection/fonts/icons/gcds-icons.woff +0 -0
- package/dist/collection/fonts/lato/LICENSE.txt +48 -0
- package/dist/collection/fonts/lato/README.md +195 -0
- package/dist/collection/fonts/lato/gcds-lato-italic.woff +0 -0
- package/dist/collection/fonts/lato/gcds-lato-italic.woff2 +0 -0
- package/dist/collection/fonts/lato/gcds-lato.css +30 -0
- package/dist/collection/fonts/lato/gcds-lato.woff +0 -0
- package/dist/collection/fonts/lato/gcds-lato.woff2 +0 -0
- package/dist/collection/fonts/noto-sans/LICENSE.txt +43 -0
- package/dist/collection/fonts/noto-sans/README.md +423 -0
- package/dist/collection/fonts/noto-sans/gcds-noto-sans-bold-italic.woff +0 -0
- package/dist/collection/fonts/noto-sans/gcds-noto-sans-bold-italic.woff2 +0 -0
- package/dist/collection/fonts/noto-sans/gcds-noto-sans-bold.woff +0 -0
- package/dist/collection/fonts/noto-sans/gcds-noto-sans-bold.woff2 +0 -0
- package/dist/collection/fonts/noto-sans/gcds-noto-sans-light-italic.woff +0 -0
- package/dist/collection/fonts/noto-sans/gcds-noto-sans-light-italic.woff2 +0 -0
- package/dist/collection/fonts/noto-sans/gcds-noto-sans-light.woff +0 -0
- package/dist/collection/fonts/noto-sans/gcds-noto-sans-light.woff2 +0 -0
- package/dist/collection/fonts/noto-sans/gcds-noto-sans-medium-italic.woff +0 -0
- package/dist/collection/fonts/noto-sans/gcds-noto-sans-medium-italic.woff2 +0 -0
- package/dist/collection/fonts/noto-sans/gcds-noto-sans-medium.woff +0 -0
- package/dist/collection/fonts/noto-sans/gcds-noto-sans-medium.woff2 +0 -0
- package/dist/collection/fonts/noto-sans/gcds-noto-sans-regular-italic.woff +0 -0
- package/dist/collection/fonts/noto-sans/gcds-noto-sans-regular-italic.woff2 +0 -0
- package/dist/collection/fonts/noto-sans/gcds-noto-sans-regular.woff +0 -0
- package/dist/collection/fonts/noto-sans/gcds-noto-sans-regular.woff2 +0 -0
- package/dist/collection/fonts/noto-sans/gcds-noto-sans-semibold-italic.woff +0 -0
- package/dist/collection/fonts/noto-sans/gcds-noto-sans-semibold-italic.woff2 +0 -0
- package/dist/collection/fonts/noto-sans/gcds-noto-sans-semibold.woff +0 -0
- package/dist/collection/fonts/noto-sans/gcds-noto-sans-semibold.woff2 +0 -0
- package/dist/collection/fonts/noto-sans/gcds-noto-sans.css +89 -0
- package/dist/collection/fonts/noto-sans-mono/LICENSE.txt +93 -0
- package/dist/collection/fonts/noto-sans-mono/README.md +135 -0
- package/dist/collection/fonts/noto-sans-mono/gcds-noto-sans-mono.css +17 -0
- package/dist/collection/fonts/noto-sans-mono/gcds-noto-sans-mono.woff +0 -0
- package/dist/collection/fonts/noto-sans-mono/gcds-noto-sans-mono.woff2 +0 -0
- package/dist/collection/generated/locale.js +148 -0
- package/dist/collection/global/mapml-globals.js +916 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/leaflet-src.esm.js +14419 -0
- package/dist/components/gcds-ext-map.d.ts +11 -0
- package/dist/components/gcds-ext-map.js +10 -0
- package/dist/components/index.d.ts +35 -0
- package/dist/components/index.js +1 -0
- package/dist/components/map-a.d.ts +11 -0
- package/dist/components/map-a.js +1 -0
- package/dist/components/map-caption.d.ts +11 -0
- package/dist/components/map-caption.js +1 -0
- package/dist/components/map-extent.d.ts +11 -0
- package/dist/components/map-extent.js +1 -0
- package/dist/components/map-feature.d.ts +11 -0
- package/dist/components/map-feature.js +1 -0
- package/dist/components/map-featurecaption.d.ts +11 -0
- package/dist/components/map-featurecaption.js +1 -0
- package/dist/components/map-geometry.d.ts +11 -0
- package/dist/components/map-geometry.js +1 -0
- package/dist/components/map-input.d.ts +11 -0
- package/dist/components/map-input.js +1 -0
- package/dist/components/map-layer.d.ts +11 -0
- package/dist/components/map-layer.js +1 -0
- package/dist/components/map-link.d.ts +11 -0
- package/dist/components/map-link.js +1 -0
- package/dist/components/map-meta.d.ts +11 -0
- package/dist/components/map-meta.js +1 -0
- package/dist/components/map-properties.d.ts +11 -0
- package/dist/components/map-properties.js +1 -0
- package/dist/components/map-select.d.ts +11 -0
- package/dist/components/map-select.js +1 -0
- package/dist/components/map-span.d.ts +11 -0
- package/dist/components/map-span.js +1 -0
- package/dist/components/map-style.d.ts +11 -0
- package/dist/components/map-style.js +1 -0
- package/dist/components/map-tile.d.ts +11 -0
- package/dist/components/map-tile.js +1 -0
- package/dist/components/p-B4YLD_Og.js +1 -0
- package/dist/components/p-BE41zrui.js +1 -0
- package/dist/components/p-Bpv_U_Lb.js +1 -0
- package/dist/components/p-CwRxGZga.js +5 -0
- package/dist/components/p-EYVT9Efh.js +1 -0
- package/dist/components/p-gwC_yeRa.js +1 -0
- package/dist/esm/AttributionButton-CfaoSLCu.js +103 -0
- package/dist/esm/MapTileLayer-DvC_iOIS.js +451 -0
- package/dist/esm/app-globals-De5ze2BD.js +773 -0
- package/dist/esm/calculatePosition-B4YLD_Og.js +90 -0
- package/dist/esm/gcds-ext-map.js +43 -0
- package/dist/esm/gcds-ext-map_2.entry.js +8078 -0
- package/dist/esm/index-BUsJ7i5g.js +32656 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +12 -0
- package/dist/esm/locale-Bpv_U_Lb.js +150 -0
- package/dist/esm/map-a.entry.js +14 -0
- package/dist/esm/map-caption.entry.js +53 -0
- package/dist/esm/map-extent.entry.js +991 -0
- package/dist/esm/map-feature.entry.js +634 -0
- package/dist/esm/map-featurecaption.entry.js +12 -0
- package/dist/esm/map-geometry.entry.js +34 -0
- package/dist/esm/map-input.entry.js +346 -0
- package/dist/esm/map-link.entry.js +6035 -0
- package/dist/esm/map-meta.entry.js +38 -0
- package/dist/esm/map-properties.entry.js +12 -0
- package/dist/esm/map-select.entry.js +98 -0
- package/dist/esm/map-span.entry.js +12 -0
- package/dist/esm/map-style.entry.js +125 -0
- package/dist/esm/map-tile.entry.js +272 -0
- package/dist/esm/renderStyles-EYVT9Efh.js +57 -0
- package/dist/gcds-ext-map/assets/canada.json +1 -0
- package/dist/gcds-ext-map/assets/images/w3community.ico +0 -0
- package/dist/gcds-ext-map/assets/mapml/en/apstile/arctic +18 -0
- package/dist/gcds-ext-map/assets/mapml/en/cbmtile/canvec +22 -0
- package/dist/gcds-ext-map/assets/mapml/en/cbmtile/cbmt +24 -0
- package/dist/gcds-ext-map/assets/mapml/en/cbmtile/cbmtgeom +20 -0
- package/dist/gcds-ext-map/assets/mapml/en/cbmtile/cbmtsimple +20 -0
- package/dist/gcds-ext-map/assets/mapml/en/cbmtile/current_conditions +33 -0
- package/dist/gcds-ext-map/assets/mapml/en/cbmtile/toporama +25 -0
- package/dist/gcds-ext-map/assets/mapml/en/custom/arcticsdi.mapml +18 -0
- package/dist/gcds-ext-map/assets/mapml/en/osmtile/cbmt +24 -0
- package/dist/gcds-ext-map/assets/mapml/en/osmtile/current_conditions +32 -0
- package/dist/gcds-ext-map/assets/mapml/en/osmtile/dark.mapml +19 -0
- package/dist/gcds-ext-map/assets/mapml/en/osmtile/light.mapml +19 -0
- package/dist/gcds-ext-map/assets/mapml/en/osmtile/osm +19 -0
- package/dist/gcds-ext-map/assets/mapml/en/osmtile/toporama +25 -0
- package/dist/gcds-ext-map/assets/mapml/fr/apstile/arctic +19 -0
- package/dist/gcds-ext-map/assets/mapml/fr/cbmtile/canvec +22 -0
- package/dist/gcds-ext-map/assets/mapml/fr/cbmtile/cbmt +24 -0
- package/dist/gcds-ext-map/assets/mapml/fr/cbmtile/cbmtgeom +20 -0
- package/dist/gcds-ext-map/assets/mapml/fr/cbmtile/cbmtsimple +20 -0
- package/dist/gcds-ext-map/assets/mapml/fr/cbmtile/current_conditions +25 -0
- package/dist/gcds-ext-map/assets/mapml/fr/cbmtile/toporama +25 -0
- package/dist/gcds-ext-map/assets/mapml/fr/osmtile/cbmt +24 -0
- package/dist/gcds-ext-map/assets/mapml/fr/osmtile/current_conditions +24 -0
- package/dist/gcds-ext-map/assets/mapml/fr/osmtile/dark.mapml +19 -0
- package/dist/gcds-ext-map/assets/mapml/fr/osmtile/light.mapml +19 -0
- package/dist/gcds-ext-map/assets/mapml/fr/osmtile/osm +19 -0
- package/dist/gcds-ext-map/assets/mapml/fr/osmtile/toporama +25 -0
- package/dist/gcds-ext-map/assets/pmtiles/darkTheme.js +19 -0
- package/dist/gcds-ext-map/assets/pmtiles/lightTheme.js +19 -0
- package/dist/gcds-ext-map/fonts/icons/LICENSE.txt +92 -0
- package/dist/gcds-ext-map/fonts/icons/README.md +543 -0
- package/dist/gcds-ext-map/fonts/icons/gcds-icons.css +110 -0
- package/dist/gcds-ext-map/fonts/icons/gcds-icons.eot +0 -0
- package/dist/gcds-ext-map/fonts/icons/gcds-icons.svg +82 -0
- package/dist/gcds-ext-map/fonts/icons/gcds-icons.ttf +0 -0
- package/dist/gcds-ext-map/fonts/icons/gcds-icons.woff +0 -0
- package/dist/gcds-ext-map/fonts/lato/LICENSE.txt +48 -0
- package/dist/gcds-ext-map/fonts/lato/README.md +195 -0
- package/dist/gcds-ext-map/fonts/lato/gcds-lato-italic.woff +0 -0
- package/dist/gcds-ext-map/fonts/lato/gcds-lato-italic.woff2 +0 -0
- package/dist/gcds-ext-map/fonts/lato/gcds-lato.css +30 -0
- package/dist/gcds-ext-map/fonts/lato/gcds-lato.woff +0 -0
- package/dist/gcds-ext-map/fonts/lato/gcds-lato.woff2 +0 -0
- package/dist/gcds-ext-map/fonts/noto-sans/LICENSE.txt +43 -0
- package/dist/gcds-ext-map/fonts/noto-sans/README.md +423 -0
- package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-bold-italic.woff +0 -0
- package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-bold-italic.woff2 +0 -0
- package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-bold.woff +0 -0
- package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-bold.woff2 +0 -0
- package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-light-italic.woff +0 -0
- package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-light-italic.woff2 +0 -0
- package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-light.woff +0 -0
- package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-light.woff2 +0 -0
- package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-medium-italic.woff +0 -0
- package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-medium-italic.woff2 +0 -0
- package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-medium.woff +0 -0
- package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-medium.woff2 +0 -0
- package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-regular-italic.woff +0 -0
- package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-regular-italic.woff2 +0 -0
- package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-regular.woff +0 -0
- package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-regular.woff2 +0 -0
- package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-semibold-italic.woff +0 -0
- package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-semibold-italic.woff2 +0 -0
- package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-semibold.woff +0 -0
- package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-semibold.woff2 +0 -0
- package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans.css +89 -0
- package/dist/gcds-ext-map/fonts/noto-sans-mono/LICENSE.txt +93 -0
- package/dist/gcds-ext-map/fonts/noto-sans-mono/README.md +135 -0
- package/dist/gcds-ext-map/fonts/noto-sans-mono/gcds-noto-sans-mono.css +17 -0
- package/dist/gcds-ext-map/fonts/noto-sans-mono/gcds-noto-sans-mono.woff +0 -0
- package/dist/gcds-ext-map/fonts/noto-sans-mono/gcds-noto-sans-mono.woff2 +0 -0
- package/dist/gcds-ext-map/gcds-ext-map.esm.js +1 -0
- package/dist/gcds-ext-map/index.esm.js +0 -0
- package/dist/gcds-ext-map/leaflet-src.esm.js +14419 -0
- package/dist/gcds-ext-map/p-1b22f774.entry.js +1 -0
- package/dist/gcds-ext-map/p-29b4ba34.entry.js +1 -0
- package/dist/gcds-ext-map/p-2dd09d44.entry.js +1 -0
- package/dist/gcds-ext-map/p-3fef47e5.entry.js +1 -0
- package/dist/gcds-ext-map/p-4e324a1d.entry.js +1 -0
- package/dist/gcds-ext-map/p-4f4a6873.entry.js +1 -0
- package/dist/gcds-ext-map/p-9cc5ad37.entry.js +1 -0
- package/dist/gcds-ext-map/p-9edfea7d.entry.js +1 -0
- package/dist/gcds-ext-map/p-B4YLD_Og.js +1 -0
- package/dist/gcds-ext-map/p-B8Id5Ptd.js +1 -0
- package/dist/gcds-ext-map/p-BUsJ7i5g.js +6 -0
- package/dist/gcds-ext-map/p-Bpv_U_Lb.js +1 -0
- package/dist/gcds-ext-map/p-CtOuMgy9.js +1 -0
- package/dist/gcds-ext-map/p-Dd474fsL.js +1 -0
- package/dist/gcds-ext-map/p-EYVT9Efh.js +1 -0
- package/dist/gcds-ext-map/p-a67d721d.entry.js +1 -0
- package/dist/gcds-ext-map/p-b16e862b.entry.js +1 -0
- package/dist/gcds-ext-map/p-b9cbf1e0.entry.js +10 -0
- package/dist/gcds-ext-map/p-cab5246e.entry.js +1 -0
- package/dist/gcds-ext-map/p-d58d409b.entry.js +1 -0
- package/dist/gcds-ext-map/p-dfa21368.entry.js +1 -0
- package/dist/gcds-ext-map/p-f211048a.entry.js +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/types/components/gcds-ext-map/gcds-ext-map.d.ts +125 -0
- package/dist/types/components/gcds-ext-map/stories/gcds-ext-map.stories.d.ts +230 -0
- package/dist/types/components/map-a/map-a.d.ts +7 -0
- package/dist/types/components/map-caption/map-caption.d.ts +7 -0
- package/dist/types/components/map-extent/map-extent.d.ts +53 -0
- package/dist/types/components/map-feature/map-feature.d.ts +50 -0
- package/dist/types/components/map-featurecaption/map-featurecaption.d.ts +3 -0
- package/dist/types/components/map-geometry/map-geometry.d.ts +7 -0
- package/dist/types/components/map-input/map-input.d.ts +24 -0
- package/dist/types/components/map-layer/map-layer.d.ts +85 -0
- package/dist/types/components/map-layer/stories/map-layer.stories.d.ts +96 -0
- package/dist/types/components/map-link/map-link.d.ts +66 -0
- package/dist/types/components/map-meta/map-meta.d.ts +11 -0
- package/dist/types/components/map-properties/map-properties.d.ts +3 -0
- package/dist/types/components/map-select/map-select.d.ts +13 -0
- package/dist/types/components/map-span/map-span.d.ts +5 -0
- package/dist/types/components/map-style/map-style.d.ts +17 -0
- package/dist/types/components/map-tile/map-tile.d.ts +32 -0
- package/dist/types/components/utils/mapml/DOMTokenList.d.ts +30 -0
- package/dist/types/components/utils/mapml/elementSupport/inputs/heightInput.d.ts +7 -0
- package/dist/types/components/utils/mapml/elementSupport/inputs/hiddenInput.d.ts +7 -0
- package/dist/types/components/utils/mapml/elementSupport/inputs/locationInput.d.ts +14 -0
- package/dist/types/components/utils/mapml/elementSupport/inputs/widthInput.d.ts +7 -0
- package/dist/types/components/utils/mapml/elementSupport/inputs/zoomInput.d.ts +11 -0
- package/dist/types/components/utils/mapml/layers/MapLayer.d.ts +69 -0
- package/dist/types/components/utils/utils.d.ts +2 -0
- package/dist/types/components.d.ts +521 -0
- package/dist/types/gcds-ext-map.d.ts +17 -0
- package/dist/types/generated/locale.d.ts +146 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/stencil-public-runtime.d.ts +1861 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/package.json +87 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Control, DomUtil } from 'leaflet';
|
|
2
|
+
|
|
3
|
+
export var ScaleBar = Control.Scale.extend({
|
|
4
|
+
options: {
|
|
5
|
+
maxWidth: 100,
|
|
6
|
+
updateWhenIdle: true,
|
|
7
|
+
position: 'bottomleft'
|
|
8
|
+
},
|
|
9
|
+
|
|
10
|
+
onAdd: function (map) {
|
|
11
|
+
// create output tag for screenreader to read from
|
|
12
|
+
let outputScale =
|
|
13
|
+
"<output role='status' aria-live='polite' aria-atomic='true' class='mapml-screen-reader-output-scale'></output>";
|
|
14
|
+
map._container.insertAdjacentHTML('beforeend', outputScale);
|
|
15
|
+
|
|
16
|
+
// initialize _container
|
|
17
|
+
this._container = DomUtil.create('div', 'mapml-control-scale');
|
|
18
|
+
let scaleControl = Control.Scale.prototype.onAdd.call(this, map);
|
|
19
|
+
this._container.appendChild(scaleControl);
|
|
20
|
+
this._container.setAttribute('tabindex', 0);
|
|
21
|
+
this._scaleControl = this;
|
|
22
|
+
|
|
23
|
+
// run on load
|
|
24
|
+
setTimeout(() => {
|
|
25
|
+
this._updateOutput();
|
|
26
|
+
this._focusOutput();
|
|
27
|
+
}, 0);
|
|
28
|
+
|
|
29
|
+
// update whenever map is zoomed or dragged
|
|
30
|
+
map.on('zoomend moveend', this._updateOutput, this);
|
|
31
|
+
|
|
32
|
+
// have screenreader read out everytime the map is focused
|
|
33
|
+
this._map._container.addEventListener('focus', () => this._focusOutput());
|
|
34
|
+
|
|
35
|
+
return this._container;
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
onRemove: function (map) {
|
|
39
|
+
map.off('zoomend moveend', this._updateOutput, this);
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
getContainer: function () {
|
|
43
|
+
return this._container;
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
_pixelsToDistance: function (px, units) {
|
|
47
|
+
let dpi = window.devicePixelRatio * 96; // default dpi
|
|
48
|
+
if (units === 'metric') {
|
|
49
|
+
return (px / dpi) * 2.54; // inches to cm
|
|
50
|
+
}
|
|
51
|
+
return px / dpi;
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
_scaleLength: function (scale) {
|
|
55
|
+
let scaleLength = scale.getAttribute('style');
|
|
56
|
+
let finalLength = parseInt(scaleLength.match(/width:\s*(\d+)px/)[1]);
|
|
57
|
+
|
|
58
|
+
return finalLength;
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
_focusOutput: function () {
|
|
62
|
+
setTimeout(() => {
|
|
63
|
+
let outputFocus = this._map._container.querySelector(
|
|
64
|
+
'.mapml-screen-reader-output-scale'
|
|
65
|
+
);
|
|
66
|
+
outputFocus.textContent = '';
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
outputFocus.textContent = this._container.getAttribute('aria-label');
|
|
69
|
+
}, 100);
|
|
70
|
+
}, 0);
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
_updateOutput: function () {
|
|
74
|
+
let output = '';
|
|
75
|
+
let scaleLine = this._scaleControl
|
|
76
|
+
.getContainer()
|
|
77
|
+
.getElementsByClassName('leaflet-control-scale-line')[0];
|
|
78
|
+
|
|
79
|
+
if (this.options.metric) {
|
|
80
|
+
let distance = parseFloat(
|
|
81
|
+
this._pixelsToDistance(this._scaleLength(scaleLine), 'metric').toFixed(
|
|
82
|
+
1
|
|
83
|
+
)
|
|
84
|
+
);
|
|
85
|
+
output = `${distance} centimeters to ${scaleLine.textContent.trim()}`;
|
|
86
|
+
output = output.replace(/(\d+)\s*m\b/g, '$1 meters');
|
|
87
|
+
output = output.replace(/ km/g, ' kilometers');
|
|
88
|
+
} else {
|
|
89
|
+
let distance = parseFloat(
|
|
90
|
+
this._pixelsToDistance(
|
|
91
|
+
this._scaleLength(scaleLine),
|
|
92
|
+
'imperial'
|
|
93
|
+
).toFixed(1)
|
|
94
|
+
);
|
|
95
|
+
output = `${distance} inches to ${scaleLine.textContent.trim()}`;
|
|
96
|
+
output = output.replace(/ft/g, 'feet');
|
|
97
|
+
output = output.replace(/mi/g, 'miles');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
this._container.setAttribute('aria-label', output);
|
|
101
|
+
this._map._container.querySelector(
|
|
102
|
+
'.mapml-screen-reader-output-scale'
|
|
103
|
+
).textContent = output;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
export var scaleBar = function (options) {
|
|
107
|
+
return new ScaleBar(options);
|
|
108
|
+
};
|
|
@@ -0,0 +1,565 @@
|
|
|
1
|
+
import { Control, DomUtil, DomEvent, latLngBounds } from 'leaflet';
|
|
2
|
+
|
|
3
|
+
export var SearchButton = Control.extend({
|
|
4
|
+
options: {
|
|
5
|
+
position: 'topleft'
|
|
6
|
+
},
|
|
7
|
+
_getLocale: function (map) {
|
|
8
|
+
return map.options.mapEl && map.options.mapEl.locale
|
|
9
|
+
? map.options.mapEl.locale
|
|
10
|
+
: M.options.locale;
|
|
11
|
+
},
|
|
12
|
+
onAdd: function (map) {
|
|
13
|
+
let locale = this._getLocale(map);
|
|
14
|
+
this._locale = locale;
|
|
15
|
+
let container = DomUtil.create('div', 'mapml-search-control leaflet-bar');
|
|
16
|
+
|
|
17
|
+
let button = DomUtil.create(
|
|
18
|
+
'button',
|
|
19
|
+
'mapml-search-button mapml-button',
|
|
20
|
+
container
|
|
21
|
+
);
|
|
22
|
+
button.setAttribute('type', 'button');
|
|
23
|
+
button.setAttribute('aria-label', locale.btnSearch || 'Search');
|
|
24
|
+
button.title = locale.btnSearch || 'Search';
|
|
25
|
+
button.innerHTML =
|
|
26
|
+
'<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" height="24" width="24" viewBox="0 0 15 15" fill="currentColor">' +
|
|
27
|
+
'<path d="M6 0C9.31 0 12 2.69 12 6C12 7.3 11.59 8.5 10.89 9.48L14.71 13.29C15.1 13.68 15.1 14.32 14.71 14.71C14.32 15.1 13.68 15.1 13.29 14.71L9.48 10.89C8.5 11.59 7.3 12 6 12C2.69 12 0 9.31 0 6C0 2.69 2.69 0 6 0ZM6 2C3.79 2 2 3.79 2 6C2 8.21 3.79 10 6 10C8.21 10 10 8.21 10 6C10 3.79 8.21 2 6 2Z"/>' +
|
|
28
|
+
'</svg>';
|
|
29
|
+
|
|
30
|
+
DomEvent.disableClickPropagation(button);
|
|
31
|
+
DomEvent.on(button, 'click', DomEvent.stop);
|
|
32
|
+
DomEvent.on(button, 'click', this._openPanel, this);
|
|
33
|
+
DomEvent.on(
|
|
34
|
+
button,
|
|
35
|
+
'keydown',
|
|
36
|
+
function (e) {
|
|
37
|
+
if (e.key === 'Enter') {
|
|
38
|
+
DomEvent.stop(e);
|
|
39
|
+
this._openPanel();
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
this
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
this._button = button;
|
|
46
|
+
|
|
47
|
+
let panel = DomUtil.create('div', 'mapml-search-panel');
|
|
48
|
+
panel.setAttribute('hidden', '');
|
|
49
|
+
map.getContainer().appendChild(panel);
|
|
50
|
+
DomEvent.disableClickPropagation(panel);
|
|
51
|
+
DomEvent.on(panel, 'mouseenter', function () {
|
|
52
|
+
map.scrollWheelZoom.disable();
|
|
53
|
+
});
|
|
54
|
+
DomEvent.on(panel, 'mouseleave', function () {
|
|
55
|
+
map.scrollWheelZoom.enable();
|
|
56
|
+
});
|
|
57
|
+
DomEvent.on(panel, 'wheel', DomEvent.stopPropagation);
|
|
58
|
+
|
|
59
|
+
let input = DomUtil.create('input', 'mapml-search-input', panel);
|
|
60
|
+
input.setAttribute('type', 'search');
|
|
61
|
+
input.setAttribute('placeholder', locale.searchPlaceholder || 'Search...');
|
|
62
|
+
input.setAttribute('aria-label', locale.btnSearch || 'Search');
|
|
63
|
+
|
|
64
|
+
DomEvent.disableClickPropagation(input);
|
|
65
|
+
DomEvent.on(
|
|
66
|
+
input,
|
|
67
|
+
'keydown',
|
|
68
|
+
function (e) {
|
|
69
|
+
if (e.key === 'Escape') {
|
|
70
|
+
DomEvent.stop(e);
|
|
71
|
+
if (this._input.value) {
|
|
72
|
+
this._input.value = '';
|
|
73
|
+
this._results.innerHTML = '';
|
|
74
|
+
} else {
|
|
75
|
+
this._closePanel();
|
|
76
|
+
}
|
|
77
|
+
} else if (e.key === 'Enter') {
|
|
78
|
+
DomEvent.stop(e);
|
|
79
|
+
if (this._debounceTimer) {
|
|
80
|
+
clearTimeout(this._debounceTimer);
|
|
81
|
+
this._debounceTimer = null;
|
|
82
|
+
}
|
|
83
|
+
this._doSearch(this._input.value.trim());
|
|
84
|
+
} else if (e.key === 'ArrowDown' || e.key === 'Down') {
|
|
85
|
+
DomEvent.stop(e);
|
|
86
|
+
let first = this._results.querySelector('.mapml-search-result');
|
|
87
|
+
if (first) first.focus();
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
this
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
// Debounced input handler for suggestions
|
|
94
|
+
this._debounceTimer = null;
|
|
95
|
+
this._abortController = null;
|
|
96
|
+
// Track IME composition to avoid searching on intermediate input
|
|
97
|
+
this._isComposing = false;
|
|
98
|
+
DomEvent.on(
|
|
99
|
+
input,
|
|
100
|
+
'compositionstart',
|
|
101
|
+
function () {
|
|
102
|
+
this._isComposing = true;
|
|
103
|
+
},
|
|
104
|
+
this
|
|
105
|
+
);
|
|
106
|
+
DomEvent.on(
|
|
107
|
+
input,
|
|
108
|
+
'compositionend',
|
|
109
|
+
function () {
|
|
110
|
+
this._isComposing = false;
|
|
111
|
+
// Trigger search after composition ends
|
|
112
|
+
let query = this._input.value.trim();
|
|
113
|
+
if (query.length < 2) {
|
|
114
|
+
this._results.innerHTML = '';
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (this._debounceTimer) clearTimeout(this._debounceTimer);
|
|
118
|
+
this._debounceTimer = setTimeout(() => {
|
|
119
|
+
this._fetchSuggestions(query);
|
|
120
|
+
}, 300);
|
|
121
|
+
},
|
|
122
|
+
this
|
|
123
|
+
);
|
|
124
|
+
DomEvent.on(
|
|
125
|
+
input,
|
|
126
|
+
'input',
|
|
127
|
+
function () {
|
|
128
|
+
if (this._isComposing) return;
|
|
129
|
+
if (this._debounceTimer) clearTimeout(this._debounceTimer);
|
|
130
|
+
let query = this._input.value.trim();
|
|
131
|
+
if (query.length < 2) {
|
|
132
|
+
this._results.innerHTML = '';
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
this._debounceTimer = setTimeout(() => {
|
|
136
|
+
this._fetchSuggestions(query);
|
|
137
|
+
}, 300);
|
|
138
|
+
},
|
|
139
|
+
this
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
this._input = input;
|
|
143
|
+
|
|
144
|
+
let results = DomUtil.create('div', 'mapml-search-results', panel);
|
|
145
|
+
this._results = results;
|
|
146
|
+
|
|
147
|
+
let closeBtn = DomUtil.create(
|
|
148
|
+
'button',
|
|
149
|
+
'mapml-search-close mapml-button',
|
|
150
|
+
panel
|
|
151
|
+
);
|
|
152
|
+
closeBtn.setAttribute('type', 'button');
|
|
153
|
+
closeBtn.setAttribute(
|
|
154
|
+
'aria-label',
|
|
155
|
+
locale.btnSearchClose || 'Close search'
|
|
156
|
+
);
|
|
157
|
+
closeBtn.title = locale.btnSearchClose || 'Close search';
|
|
158
|
+
closeBtn.innerHTML =
|
|
159
|
+
'<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" height="18" width="18" viewBox="0 0 24 24" fill="currentColor">' +
|
|
160
|
+
'<path d="M15.41 16.59L10.83 12l4.58-4.59L14 6l-6 6 6 6 1.41-1.41z"/>' +
|
|
161
|
+
'</svg>';
|
|
162
|
+
|
|
163
|
+
DomEvent.disableClickPropagation(closeBtn);
|
|
164
|
+
DomEvent.on(closeBtn, 'click', DomEvent.stop);
|
|
165
|
+
DomEvent.on(closeBtn, 'click', this._closePanel, this);
|
|
166
|
+
|
|
167
|
+
this._closeBtn = closeBtn;
|
|
168
|
+
this._panel = panel;
|
|
169
|
+
|
|
170
|
+
this._mapEl = map.options.mapEl;
|
|
171
|
+
|
|
172
|
+
// Set up layer observation for disabled state
|
|
173
|
+
this._onLoadedMetadata = () => this._updateDisabled();
|
|
174
|
+
this._layerObserver = new MutationObserver((mutations) => {
|
|
175
|
+
this._updateDisabled();
|
|
176
|
+
// When new layers are added, listen for their loadedmetadata
|
|
177
|
+
for (let mutation of mutations) {
|
|
178
|
+
for (let node of mutation.addedNodes) {
|
|
179
|
+
if (
|
|
180
|
+
node.nodeName &&
|
|
181
|
+
(node.nodeName.toUpperCase() === 'MAP-LAYER' ||
|
|
182
|
+
node.nodeName.toUpperCase() === 'LAYER-')
|
|
183
|
+
) {
|
|
184
|
+
node.addEventListener('loadedmetadata', this._onLoadedMetadata);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
this._layerObserver.observe(this._mapEl, {
|
|
190
|
+
childList: true,
|
|
191
|
+
subtree: true,
|
|
192
|
+
attributes: true,
|
|
193
|
+
attributeFilter: ['checked', 'rel']
|
|
194
|
+
});
|
|
195
|
+
// Attach loadedmetadata listener to existing layers
|
|
196
|
+
this._mapEl
|
|
197
|
+
.querySelectorAll('map-layer, layer-')
|
|
198
|
+
.forEach((layer) =>
|
|
199
|
+
layer.addEventListener('loadedmetadata', this._onLoadedMetadata)
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
this._updateDisabled();
|
|
203
|
+
|
|
204
|
+
return container;
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
onRemove: function () {
|
|
208
|
+
if (this._panel && this._panel.parentNode) {
|
|
209
|
+
this._panel.parentNode.removeChild(this._panel);
|
|
210
|
+
}
|
|
211
|
+
if (this._layerObserver) {
|
|
212
|
+
this._layerObserver.disconnect();
|
|
213
|
+
}
|
|
214
|
+
if (this._mapEl) {
|
|
215
|
+
this._mapEl
|
|
216
|
+
.querySelectorAll('map-layer, layer-')
|
|
217
|
+
.forEach((layer) =>
|
|
218
|
+
layer.removeEventListener('loadedmetadata', this._onLoadedMetadata)
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
DomEvent.off(this._button, 'click', this._openPanel, this);
|
|
222
|
+
DomEvent.off(this._closeBtn, 'click', this._closePanel, this);
|
|
223
|
+
},
|
|
224
|
+
|
|
225
|
+
_hasSearchLayers: function () {
|
|
226
|
+
let layers = this._mapEl.querySelectorAll(
|
|
227
|
+
'map-layer[checked], layer-[checked]'
|
|
228
|
+
);
|
|
229
|
+
for (let layer of layers) {
|
|
230
|
+
let root = layer.src ? layer.shadowRoot : layer;
|
|
231
|
+
if (root && root.querySelector('map-link[rel=search]')) {
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return false;
|
|
236
|
+
},
|
|
237
|
+
|
|
238
|
+
_updateDisabled: function () {
|
|
239
|
+
let hasSearch = this._hasSearchLayers();
|
|
240
|
+
if (hasSearch) {
|
|
241
|
+
this._button.setAttribute('aria-disabled', 'false');
|
|
242
|
+
} else {
|
|
243
|
+
this._button.setAttribute('aria-disabled', 'true');
|
|
244
|
+
// If panel is open, close it
|
|
245
|
+
if (!this._panel.hasAttribute('hidden')) {
|
|
246
|
+
this._closePanel();
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
|
|
251
|
+
_openPanel: function () {
|
|
252
|
+
if (this._button.getAttribute('aria-disabled') === 'true') return;
|
|
253
|
+
this._panel.removeAttribute('hidden');
|
|
254
|
+
this._input.value = '';
|
|
255
|
+
this._results.innerHTML = '';
|
|
256
|
+
setTimeout(() => {
|
|
257
|
+
this._panel.classList.add('mapml-search-panel-open');
|
|
258
|
+
this._input.focus();
|
|
259
|
+
}, 0);
|
|
260
|
+
},
|
|
261
|
+
|
|
262
|
+
_closePanel: function () {
|
|
263
|
+
this._panel.classList.remove('mapml-search-panel-open');
|
|
264
|
+
if (this._abortController) {
|
|
265
|
+
this._abortController.abort();
|
|
266
|
+
this._abortController = null;
|
|
267
|
+
}
|
|
268
|
+
if (this._debounceTimer) {
|
|
269
|
+
clearTimeout(this._debounceTimer);
|
|
270
|
+
this._debounceTimer = null;
|
|
271
|
+
}
|
|
272
|
+
let onEnd = () => {
|
|
273
|
+
this._panel.setAttribute('hidden', '');
|
|
274
|
+
this._button.focus();
|
|
275
|
+
this._panel.removeEventListener('transitionend', onEnd);
|
|
276
|
+
};
|
|
277
|
+
this._panel.addEventListener('transitionend', onEnd);
|
|
278
|
+
setTimeout(onEnd, 300);
|
|
279
|
+
},
|
|
280
|
+
|
|
281
|
+
_getLinks: function (rel) {
|
|
282
|
+
let results = [];
|
|
283
|
+
let layers = this._mapEl.querySelectorAll(
|
|
284
|
+
'map-layer[checked], layer-[checked]'
|
|
285
|
+
);
|
|
286
|
+
for (let layer of layers) {
|
|
287
|
+
let root = layer.src ? layer.shadowRoot : layer;
|
|
288
|
+
if (root) {
|
|
289
|
+
let link = root.querySelector('map-link[rel=' + rel + ']');
|
|
290
|
+
if (link) {
|
|
291
|
+
results.push({ link: link, layer: layer });
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return results;
|
|
296
|
+
},
|
|
297
|
+
|
|
298
|
+
_getSearchLinks: function () {
|
|
299
|
+
return this._getLinks('search');
|
|
300
|
+
},
|
|
301
|
+
|
|
302
|
+
_getSuggestionsLinks: function () {
|
|
303
|
+
return this._getLinks('suggestions');
|
|
304
|
+
},
|
|
305
|
+
|
|
306
|
+
_resolveUrl: function (link, query) {
|
|
307
|
+
let tref = link.getAttribute('tref') || '';
|
|
308
|
+
let url = tref.replace('{searchTerms}', encodeURIComponent(query));
|
|
309
|
+
if (link.getBase) {
|
|
310
|
+
try {
|
|
311
|
+
return new URL(url, link.getBase()).href;
|
|
312
|
+
} catch (e) {
|
|
313
|
+
return url;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return url;
|
|
317
|
+
},
|
|
318
|
+
|
|
319
|
+
_fetchSuggestions: function (query) {
|
|
320
|
+
if (this._button.getAttribute('aria-disabled') === 'true') return;
|
|
321
|
+
let suggestionsLinks = this._getSuggestionsLinks();
|
|
322
|
+
if (suggestionsLinks.length === 0) return;
|
|
323
|
+
|
|
324
|
+
if (this._abortController) this._abortController.abort();
|
|
325
|
+
this._abortController = new AbortController();
|
|
326
|
+
let signal = this._abortController.signal;
|
|
327
|
+
|
|
328
|
+
let fetches = suggestionsLinks.map(({ link, layer }) => {
|
|
329
|
+
let url = this._resolveUrl(link, query);
|
|
330
|
+
return fetch(url, { signal })
|
|
331
|
+
.then((r) => r.json())
|
|
332
|
+
.then((data) => ({ data, link, layer }));
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
Promise.allSettled(fetches).then((settled) => {
|
|
336
|
+
if (signal.aborted) return;
|
|
337
|
+
let responses = settled
|
|
338
|
+
.filter((s) => s.status === 'fulfilled')
|
|
339
|
+
.map((s) => s.value);
|
|
340
|
+
|
|
341
|
+
let event = new CustomEvent('mapsuggestions', {
|
|
342
|
+
bubbles: true,
|
|
343
|
+
cancelable: true,
|
|
344
|
+
detail: {
|
|
345
|
+
query,
|
|
346
|
+
responses,
|
|
347
|
+
setResults: this._setResults.bind(this)
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
let cancelled = !this._mapEl.dispatchEvent(event);
|
|
351
|
+
if (!cancelled) {
|
|
352
|
+
this._defaultSuggestionsHandler({ query, responses });
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
},
|
|
356
|
+
|
|
357
|
+
_doSearch: function (query) {
|
|
358
|
+
if (!query || this._button.getAttribute('aria-disabled') === 'true') return;
|
|
359
|
+
let searchLinks = this._getSearchLinks();
|
|
360
|
+
if (searchLinks.length === 0) return;
|
|
361
|
+
|
|
362
|
+
if (this._abortController) this._abortController.abort();
|
|
363
|
+
this._abortController = new AbortController();
|
|
364
|
+
let signal = this._abortController.signal;
|
|
365
|
+
|
|
366
|
+
let fetches = searchLinks.map(({ link, layer }) => {
|
|
367
|
+
let url = this._resolveUrl(link, query);
|
|
368
|
+
return fetch(url, { signal })
|
|
369
|
+
.then((r) => r.json())
|
|
370
|
+
.then((data) => ({ data, link, layer }));
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
Promise.allSettled(fetches).then((settled) => {
|
|
374
|
+
if (signal.aborted) return;
|
|
375
|
+
let responses = settled
|
|
376
|
+
.filter((s) => s.status === 'fulfilled')
|
|
377
|
+
.map((s) => s.value);
|
|
378
|
+
|
|
379
|
+
let event = new CustomEvent('mapsearch', {
|
|
380
|
+
bubbles: true,
|
|
381
|
+
cancelable: true,
|
|
382
|
+
detail: {
|
|
383
|
+
query,
|
|
384
|
+
responses,
|
|
385
|
+
setResults: this._setResults.bind(this)
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
let cancelled = !this._mapEl.dispatchEvent(event);
|
|
389
|
+
if (!cancelled) {
|
|
390
|
+
this._defaultSearchHandler({ query, responses });
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
},
|
|
394
|
+
|
|
395
|
+
_defaultSuggestionsHandler: function ({ query, responses }) {
|
|
396
|
+
this._renderResults(responses);
|
|
397
|
+
},
|
|
398
|
+
|
|
399
|
+
_defaultSearchHandler: function ({ query, responses }) {
|
|
400
|
+
this._renderResults(responses);
|
|
401
|
+
// Navigate to the first result
|
|
402
|
+
for (let { data } of responses) {
|
|
403
|
+
if (!data || !data.features) continue;
|
|
404
|
+
for (let feature of data.features) {
|
|
405
|
+
this._navigateToFeature(feature);
|
|
406
|
+
break;
|
|
407
|
+
}
|
|
408
|
+
break;
|
|
409
|
+
}
|
|
410
|
+
// Keep focus on the search input so the user can refine or review
|
|
411
|
+
this._input.focus();
|
|
412
|
+
},
|
|
413
|
+
|
|
414
|
+
_navigateToFeature: function (feature) {
|
|
415
|
+
let map = this._map;
|
|
416
|
+
// Standard GeoJSON bbox
|
|
417
|
+
let bbox = feature.bbox;
|
|
418
|
+
// Photon stores extent in properties.extent [west, south, east, north]
|
|
419
|
+
if (
|
|
420
|
+
(!bbox || bbox.length !== 4) &&
|
|
421
|
+
feature.properties &&
|
|
422
|
+
feature.properties.extent &&
|
|
423
|
+
feature.properties.extent.length === 4
|
|
424
|
+
) {
|
|
425
|
+
bbox = feature.properties.extent;
|
|
426
|
+
}
|
|
427
|
+
if (bbox && bbox.length === 4) {
|
|
428
|
+
let [west, south, east, north] = bbox;
|
|
429
|
+
map.fitBounds(latLngBounds([south, west], [north, east]));
|
|
430
|
+
} else if (
|
|
431
|
+
feature.geometry &&
|
|
432
|
+
feature.geometry.coordinates &&
|
|
433
|
+
feature.geometry.coordinates.length >= 2
|
|
434
|
+
) {
|
|
435
|
+
let [lon, lat] = feature.geometry.coordinates;
|
|
436
|
+
let zoom = (feature.properties && feature.properties.zoom) || 14;
|
|
437
|
+
map.setView([lat, lon], zoom);
|
|
438
|
+
}
|
|
439
|
+
},
|
|
440
|
+
|
|
441
|
+
_renderResults: function (responses) {
|
|
442
|
+
this._results.innerHTML = '';
|
|
443
|
+
for (let { data, layer } of responses) {
|
|
444
|
+
if (!data || !data.features) continue;
|
|
445
|
+
for (let feature of data.features) {
|
|
446
|
+
let btn = document.createElement('button');
|
|
447
|
+
btn.className = 'mapml-search-result';
|
|
448
|
+
btn.setAttribute('type', 'button');
|
|
449
|
+
btn.textContent = this._formatResultName(feature.properties);
|
|
450
|
+
btn.addEventListener(
|
|
451
|
+
'click',
|
|
452
|
+
(
|
|
453
|
+
(f, l) => () =>
|
|
454
|
+
this._selectResult(f, l)
|
|
455
|
+
)(feature, layer)
|
|
456
|
+
);
|
|
457
|
+
btn.addEventListener('keydown', this._resultKeydown.bind(this));
|
|
458
|
+
this._results.appendChild(btn);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
},
|
|
462
|
+
|
|
463
|
+
_resultKeydown: function (e) {
|
|
464
|
+
let btn = e.target;
|
|
465
|
+
let prev = btn.previousElementSibling;
|
|
466
|
+
let next = btn.nextElementSibling;
|
|
467
|
+
if (
|
|
468
|
+
e.key === 'ArrowDown' ||
|
|
469
|
+
e.key === 'ArrowRight' ||
|
|
470
|
+
e.key === 'Down' ||
|
|
471
|
+
e.key === 'Right'
|
|
472
|
+
) {
|
|
473
|
+
DomEvent.stop(e);
|
|
474
|
+
if (next && next.classList.contains('mapml-search-result')) {
|
|
475
|
+
next.focus();
|
|
476
|
+
}
|
|
477
|
+
} else if (
|
|
478
|
+
e.key === 'ArrowUp' ||
|
|
479
|
+
e.key === 'ArrowLeft' ||
|
|
480
|
+
e.key === 'Up' ||
|
|
481
|
+
e.key === 'Left'
|
|
482
|
+
) {
|
|
483
|
+
DomEvent.stop(e);
|
|
484
|
+
if (prev && prev.classList.contains('mapml-search-result')) {
|
|
485
|
+
prev.focus();
|
|
486
|
+
} else {
|
|
487
|
+
this._input.focus();
|
|
488
|
+
}
|
|
489
|
+
} else if (e.key === 'Escape') {
|
|
490
|
+
DomEvent.stop(e);
|
|
491
|
+
this._input.focus();
|
|
492
|
+
}
|
|
493
|
+
},
|
|
494
|
+
|
|
495
|
+
_formatResultName: function (props) {
|
|
496
|
+
if (!props) return this._locale?.searchResultWithNoName || 'Unnamed';
|
|
497
|
+
if (props.display_name) return props.display_name;
|
|
498
|
+
let parts = [props.name];
|
|
499
|
+
// Build context from common geocoder properties (Photon, etc.)
|
|
500
|
+
for (let key of ['city', 'county', 'state', 'country']) {
|
|
501
|
+
if (props[key] && props[key] !== props.name) parts.push(props[key]);
|
|
502
|
+
}
|
|
503
|
+
return (
|
|
504
|
+
parts.filter(Boolean).join(', ') ||
|
|
505
|
+
this._locale?.searchResultWithNoName ||
|
|
506
|
+
'Unnamed'
|
|
507
|
+
);
|
|
508
|
+
},
|
|
509
|
+
|
|
510
|
+
_selectResult: function (feature, layer) {
|
|
511
|
+
// Use the suggestion's display name as a refined search query
|
|
512
|
+
let name = this._formatResultName(feature.properties);
|
|
513
|
+
this._input.value = name;
|
|
514
|
+
this._doSearch(name);
|
|
515
|
+
},
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Public API for custom event handlers.
|
|
519
|
+
* Renders items as buttons in the results dropdown.
|
|
520
|
+
*
|
|
521
|
+
* Item shape: { text, value?, lat?, lng?, bbox? }
|
|
522
|
+
* - text (required): display string
|
|
523
|
+
* - value: if present, clicking triggers _doSearch(value)
|
|
524
|
+
* - lat/lng/bbox: if present and value is absent, clicking navigates
|
|
525
|
+
*/
|
|
526
|
+
_setResults: function (items) {
|
|
527
|
+
this._results.innerHTML = '';
|
|
528
|
+
if (!items || !Array.isArray(items)) return;
|
|
529
|
+
for (let item of items) {
|
|
530
|
+
let btn = document.createElement('button');
|
|
531
|
+
btn.className = 'mapml-search-result';
|
|
532
|
+
btn.setAttribute('type', 'button');
|
|
533
|
+
btn.textContent = item.text || '';
|
|
534
|
+
btn.addEventListener(
|
|
535
|
+
'click',
|
|
536
|
+
((it) => () => {
|
|
537
|
+
if (it.value != null) {
|
|
538
|
+
// Suggestion mode: refine the search
|
|
539
|
+
this._input.value = it.value;
|
|
540
|
+
this._doSearch(it.value);
|
|
541
|
+
} else {
|
|
542
|
+
// Result mode: navigate to location
|
|
543
|
+
this._navigateToItem(it);
|
|
544
|
+
}
|
|
545
|
+
})(item)
|
|
546
|
+
);
|
|
547
|
+
btn.addEventListener('keydown', this._resultKeydown.bind(this));
|
|
548
|
+
this._results.appendChild(btn);
|
|
549
|
+
}
|
|
550
|
+
},
|
|
551
|
+
|
|
552
|
+
_navigateToItem: function (item) {
|
|
553
|
+
let map = this._map;
|
|
554
|
+
if (item.bbox && item.bbox.length === 4) {
|
|
555
|
+
let [west, south, east, north] = item.bbox;
|
|
556
|
+
map.fitBounds(latLngBounds([south, west], [north, east]));
|
|
557
|
+
} else if (item.lat != null && item.lng != null) {
|
|
558
|
+
map.setView([item.lat, item.lng], 14);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
});
|
|
562
|
+
|
|
563
|
+
export var searchButton = function (options) {
|
|
564
|
+
return new SearchButton(options);
|
|
565
|
+
};
|