@trailstash/ultra 3.0.0-dev
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/.gitlab-ci.yml +15 -0
- package/Examples/alt-bbox-format.ultra +9 -0
- package/Examples/atp-usps-dropboxes.ultra +68 -0
- package/Examples/bike-infra.ultra +111 -0
- package/Examples/contribution-heatmap.ultra +17 -0
- package/Examples/custom-style.ultra +114 -0
- package/Examples/glow-effect.ultra +27 -0
- package/Examples/index.md +7 -0
- package/Examples/landmarks-prototype.ultra +68 -0
- package/Examples/minimalist-ski-map.ultra +55 -0
- package/Examples/opentrailstash-3d.ultra +40 -0
- package/Examples/overture-landcover-plus-hillshade.ultra +45 -0
- package/Examples/overture-places-and-osm.ultra +29 -0
- package/Examples/trees.ultra +60 -0
- package/Examples/wikidata-photo.ultra +28 -0
- package/Examples/within-bounds.ultra +12 -0
- package/LICENSE +23 -0
- package/MapLibre-Examples/3d-buildings.ultra +43 -0
- package/MapLibre-Examples/3d-extrusion-floorplan.ultra +28 -0
- package/MapLibre-Examples/3d-terrain.ultra +39 -0
- package/MapLibre-Examples/add-image.ultra +26 -0
- package/MapLibre-Examples/attribution-position.ultra +12 -0
- package/MapLibre-Examples/change-case-of-labels.ultra +26 -0
- package/MapLibre-Examples/cluster.ultra +59 -0
- package/MapLibre-Examples/cooperative-gestures.ultra +11 -0
- package/MapLibre-Examples/custom-marker-icons.ultra +65 -0
- package/MapLibre-Examples/data-driven-lines.ultra +169 -0
- package/MapLibre-Examples/disable-rotation.ultra +11 -0
- package/MapLibre-Examples/disable-scroll-zoom.ultra +9 -0
- package/MapLibre-Examples/display-and-style-rich-text-labels.ultra +22 -0
- package/MapLibre-Examples/fill-pattern.ultra +43 -0
- package/MapLibre-Examples/fullscreen.ultra +10 -0
- package/MapLibre-Examples/geojson-layer-in-stack.ultra +23 -0
- package/MapLibre-Examples/geojson-line.ultra +114 -0
- package/MapLibre-Examples/geojson-markers.ultra +217 -0
- package/MapLibre-Examples/geojson-polygon.ultra +104 -0
- package/MapLibre-Examples/heatmap-layer.ultra +111 -0
- package/MapLibre-Examples/index.md +4 -0
- package/MapLibre-Examples/locate-user.ultra +14 -0
- package/MapLibre-Examples/map-tiles.ultra +9 -0
- package/MapLibre-Examples/pmtiles.ultra +25 -0
- package/MapLibre-Examples/wms.ultra +14 -0
- package/README.md +46 -0
- package/bin/dev.cmd +3 -0
- package/bin/dev.js +6 -0
- package/bin/run.cmd +3 -0
- package/bin/run.js +5 -0
- package/build-examples-docs.js +104 -0
- package/build-examples-images.js +87 -0
- package/build-sprites.sh +30 -0
- package/cli/build.js +53 -0
- package/cli/serve.js +34 -0
- package/components/button-modal.js +111 -0
- package/components/button.css +22 -0
- package/components/button.js +6 -0
- package/components/code-editor.js +87 -0
- package/components/download-button.js +69 -0
- package/components/fontawesome-icon.js +80 -0
- package/components/fs-button.js +52 -0
- package/components/help-modal.js +98 -0
- package/components/map-popup.js +57 -0
- package/components/nav-bar.js +76 -0
- package/components/run-button.js +78 -0
- package/components/share-button.js +35 -0
- package/components/share-modal.js +139 -0
- package/components/style-picker.js +47 -0
- package/components/ultra-ide.js +298 -0
- package/components/ultra-loader.js +60 -0
- package/components/ultra-map.js +312 -0
- package/configs/minimal.js +9 -0
- package/configs/overpass-ultra.js +185 -0
- package/docs/assets/Examples/alt-bbox-format.png +0 -0
- package/docs/assets/Examples/atp-usps-dropboxes.png +0 -0
- package/docs/assets/Examples/bike-infra.png +0 -0
- package/docs/assets/Examples/contribution-heatmap.png +0 -0
- package/docs/assets/Examples/custom-style.png +0 -0
- package/docs/assets/Examples/glow-effect.png +0 -0
- package/docs/assets/Examples/landmarks-prototype.png +0 -0
- package/docs/assets/Examples/minimalist-ski-map.png +0 -0
- package/docs/assets/Examples/opentrailstash-3d.png +0 -0
- package/docs/assets/Examples/overture-landcover-plus-hillshade.png +0 -0
- package/docs/assets/Examples/overture-places-and-osm.png +0 -0
- package/docs/assets/Examples/trees.png +0 -0
- package/docs/assets/Examples/wikidata-photo.png +0 -0
- package/docs/assets/Examples/within-bounds.png +0 -0
- package/docs/assets/MapLibre-Examples/3d-buildings.png +0 -0
- package/docs/assets/MapLibre-Examples/3d-extrusion-floorplan.png +0 -0
- package/docs/assets/MapLibre-Examples/3d-terrain.png +0 -0
- package/docs/assets/MapLibre-Examples/add-image.png +0 -0
- package/docs/assets/MapLibre-Examples/attribution-position.png +0 -0
- package/docs/assets/MapLibre-Examples/change-case-of-labels.png +0 -0
- package/docs/assets/MapLibre-Examples/cluster.png +0 -0
- package/docs/assets/MapLibre-Examples/cooperative-gestures.png +0 -0
- package/docs/assets/MapLibre-Examples/custom-marker-icons.png +0 -0
- package/docs/assets/MapLibre-Examples/data-driven-lines.png +0 -0
- package/docs/assets/MapLibre-Examples/disable-rotation.png +0 -0
- package/docs/assets/MapLibre-Examples/disable-scroll-zoom.png +0 -0
- package/docs/assets/MapLibre-Examples/display-and-style-rich-text-labels.png +0 -0
- package/docs/assets/MapLibre-Examples/fill-pattern.png +0 -0
- package/docs/assets/MapLibre-Examples/fullscreen.png +0 -0
- package/docs/assets/MapLibre-Examples/geojson-layer-in-stack.png +0 -0
- package/docs/assets/MapLibre-Examples/geojson-line.png +0 -0
- package/docs/assets/MapLibre-Examples/geojson-markers.png +0 -0
- package/docs/assets/MapLibre-Examples/geojson-polygon.png +0 -0
- package/docs/assets/MapLibre-Examples/heatmap-layer.png +0 -0
- package/docs/assets/MapLibre-Examples/locate-user.png +0 -0
- package/docs/assets/MapLibre-Examples/map-tiles.png +0 -0
- package/docs/assets/MapLibre-Examples/pmtiles.png +0 -0
- package/docs/assets/MapLibre-Examples/wms.png +0 -0
- package/docs/assets/data/Examples/atp_usps_collection_boxes.geojson +1 -0
- package/docs/further-reading.md +15 -0
- package/docs/index.md +55 -0
- package/docs/overrides/partials/integrations/analytics/custom.html +11 -0
- package/docs/query-shortcuts.md +21 -0
- package/docs/style.md +120 -0
- package/docs/url-parameters.md +45 -0
- package/docs/yaml.md +117 -0
- package/index.js +53 -0
- package/lib/base.css +12 -0
- package/lib/bounds.js +8 -0
- package/lib/dom.js +21 -0
- package/lib/glyphFallback.js +31 -0
- package/lib/localStorage.js +34 -0
- package/lib/normalize.js +5 -0
- package/lib/queryMap.js +50 -0
- package/lib/queryParams.js +142 -0
- package/lib/queryProviders/auto.js +47 -0
- package/lib/queryProviders/geojson.js +134 -0
- package/lib/queryProviders/gpx.js +101 -0
- package/lib/queryProviders/index.js +22 -0
- package/lib/queryProviders/kml.js +132 -0
- package/lib/queryProviders/osm.js +199 -0
- package/lib/queryProviders/overpass.js +162 -0
- package/lib/queryProviders/raster.js +23 -0
- package/lib/queryProviders/tcx.js +105 -0
- package/lib/queryProviders/vector.js +13 -0
- package/lib/settings.js +72 -0
- package/lib/sprites.js +18 -0
- package/lib/style.js +222 -0
- package/mkdocs.yml +26 -0
- package/package.json +80 -0
- package/screenshot.png +0 -0
- package/static/embed.js +18 -0
- package/static/font/0-255.pbf +0 -0
- package/static/font/1024-1279.pbf +0 -0
- package/static/font/10240-10495.pbf +3 -0
- package/static/font/10496-10751.pbf +0 -0
- package/static/font/10752-11007.pbf +3 -0
- package/static/font/11008-11263.pbf +0 -0
- package/static/font/11264-11519.pbf +0 -0
- package/static/font/11520-11775.pbf +0 -0
- package/static/font/11776-12031.pbf +0 -0
- package/static/font/12032-12287.pbf +0 -0
- package/static/font/12288-12543.pbf +0 -0
- package/static/font/12544-12799.pbf +0 -0
- package/static/font/1280-1535.pbf +0 -0
- package/static/font/12800-13055.pbf +0 -0
- package/static/font/13056-13311.pbf +0 -0
- package/static/font/13312-13567.pbf +0 -0
- package/static/font/13568-13823.pbf +0 -0
- package/static/font/13824-14079.pbf +0 -0
- package/static/font/14080-14335.pbf +0 -0
- package/static/font/14336-14591.pbf +0 -0
- package/static/font/14592-14847.pbf +0 -0
- package/static/font/14848-15103.pbf +0 -0
- package/static/font/15104-15359.pbf +0 -0
- package/static/font/1536-1791.pbf +0 -0
- package/static/font/15360-15615.pbf +0 -0
- package/static/font/15616-15871.pbf +0 -0
- package/static/font/15872-16127.pbf +0 -0
- package/static/font/16128-16383.pbf +0 -0
- package/static/font/16384-16639.pbf +0 -0
- package/static/font/16640-16895.pbf +0 -0
- package/static/font/16896-17151.pbf +0 -0
- package/static/font/17152-17407.pbf +0 -0
- package/static/font/17408-17663.pbf +0 -0
- package/static/font/17664-17919.pbf +0 -0
- package/static/font/1792-2047.pbf +0 -0
- package/static/font/17920-18175.pbf +0 -0
- package/static/font/18176-18431.pbf +0 -0
- package/static/font/18432-18687.pbf +0 -0
- package/static/font/18688-18943.pbf +0 -0
- package/static/font/18944-19199.pbf +0 -0
- package/static/font/19200-19455.pbf +0 -0
- package/static/font/19456-19711.pbf +0 -0
- package/static/font/19712-19967.pbf +0 -0
- package/static/font/19968-20223.pbf +0 -0
- package/static/font/20224-20479.pbf +0 -0
- package/static/font/2048-2303.pbf +0 -0
- package/static/font/20480-20735.pbf +0 -0
- package/static/font/20736-20991.pbf +0 -0
- package/static/font/20992-21247.pbf +0 -0
- package/static/font/21248-21503.pbf +0 -0
- package/static/font/21504-21759.pbf +0 -0
- package/static/font/21760-22015.pbf +0 -0
- package/static/font/22016-22271.pbf +0 -0
- package/static/font/22272-22527.pbf +192 -26
- package/static/font/22528-22783.pbf +0 -0
- package/static/font/22784-23039.pbf +0 -0
- package/static/font/2304-2559.pbf +0 -0
- package/static/font/23040-23295.pbf +0 -0
- package/static/font/23296-23551.pbf +0 -0
- package/static/font/23552-23807.pbf +0 -0
- package/static/font/23808-24063.pbf +0 -0
- package/static/font/24064-24319.pbf +0 -0
- package/static/font/24320-24575.pbf +0 -0
- package/static/font/24576-24831.pbf +0 -0
- package/static/font/24832-25087.pbf +0 -0
- package/static/font/25088-25343.pbf +0 -0
- package/static/font/25344-25599.pbf +0 -0
- package/static/font/256-511.pbf +0 -0
- package/static/font/2560-2815.pbf +0 -0
- package/static/font/25600-25855.pbf +0 -0
- package/static/font/25856-26111.pbf +0 -0
- package/static/font/26112-26367.pbf +0 -0
- package/static/font/26368-26623.pbf +0 -0
- package/static/font/26624-26879.pbf +0 -0
- package/static/font/26880-27135.pbf +0 -0
- package/static/font/27136-27391.pbf +0 -0
- package/static/font/27392-27647.pbf +0 -0
- package/static/font/27648-27903.pbf +0 -0
- package/static/font/27904-28159.pbf +0 -0
- package/static/font/2816-3071.pbf +0 -0
- package/static/font/28160-28415.pbf +0 -0
- package/static/font/28416-28671.pbf +0 -0
- package/static/font/28672-28927.pbf +0 -0
- package/static/font/28928-29183.pbf +0 -0
- package/static/font/29184-29439.pbf +0 -0
- package/static/font/29440-29695.pbf +0 -0
- package/static/font/29696-29951.pbf +0 -0
- package/static/font/29952-30207.pbf +0 -0
- package/static/font/30208-30463.pbf +0 -0
- package/static/font/30464-30719.pbf +0 -0
- package/static/font/3072-3327.pbf +0 -0
- package/static/font/30720-30975.pbf +0 -0
- package/static/font/30976-31231.pbf +0 -0
- package/static/font/31232-31487.pbf +0 -0
- package/static/font/31488-31743.pbf +0 -0
- package/static/font/31744-31999.pbf +0 -0
- package/static/font/32000-32255.pbf +0 -0
- package/static/font/32256-32511.pbf +0 -0
- package/static/font/32512-32767.pbf +0 -0
- package/static/font/32768-33023.pbf +0 -0
- package/static/font/33024-33279.pbf +0 -0
- package/static/font/3328-3583.pbf +0 -0
- package/static/font/33280-33535.pbf +0 -0
- package/static/font/33536-33791.pbf +0 -0
- package/static/font/33792-34047.pbf +0 -0
- package/static/font/34048-34303.pbf +0 -0
- package/static/font/34304-34559.pbf +0 -0
- package/static/font/34560-34815.pbf +0 -0
- package/static/font/34816-35071.pbf +0 -0
- package/static/font/35072-35327.pbf +0 -0
- package/static/font/35328-35583.pbf +0 -0
- package/static/font/35584-35839.pbf +0 -0
- package/static/font/3584-3839.pbf +0 -0
- package/static/font/35840-36095.pbf +0 -0
- package/static/font/36096-36351.pbf +0 -0
- package/static/font/36352-36607.pbf +0 -0
- package/static/font/36608-36863.pbf +0 -0
- package/static/font/36864-37119.pbf +0 -0
- package/static/font/37120-37375.pbf +0 -0
- package/static/font/37376-37631.pbf +0 -0
- package/static/font/37632-37887.pbf +0 -0
- package/static/font/37888-38143.pbf +0 -0
- package/static/font/38144-38399.pbf +0 -0
- package/static/font/3840-4095.pbf +0 -0
- package/static/font/38400-38655.pbf +45 -4
- package/static/font/38656-38911.pbf +0 -0
- package/static/font/38912-39167.pbf +0 -0
- package/static/font/39168-39423.pbf +0 -0
- package/static/font/39424-39679.pbf +0 -0
- package/static/font/39680-39935.pbf +0 -0
- package/static/font/39936-40191.pbf +0 -0
- package/static/font/40192-40447.pbf +0 -0
- package/static/font/40448-40703.pbf +0 -0
- package/static/font/40704-40959.pbf +0 -0
- package/static/font/4096-4351.pbf +0 -0
- package/static/font/40960-41215.pbf +3 -0
- package/static/font/41216-41471.pbf +3 -0
- package/static/font/41472-41727.pbf +3 -0
- package/static/font/41728-41983.pbf +3 -0
- package/static/font/41984-42239.pbf +3 -0
- package/static/font/42240-42495.pbf +3 -0
- package/static/font/42496-42751.pbf +3 -0
- package/static/font/42752-43007.pbf +0 -0
- package/static/font/43008-43263.pbf +0 -0
- package/static/font/43264-43519.pbf +0 -0
- package/static/font/4352-4607.pbf +0 -0
- package/static/font/43520-43775.pbf +0 -0
- package/static/font/43776-44031.pbf +0 -0
- package/static/font/44032-44287.pbf +0 -0
- package/static/font/44288-44543.pbf +0 -0
- package/static/font/44544-44799.pbf +0 -0
- package/static/font/44800-45055.pbf +0 -0
- package/static/font/45056-45311.pbf +0 -0
- package/static/font/45312-45567.pbf +0 -0
- package/static/font/45568-45823.pbf +0 -0
- package/static/font/45824-46079.pbf +0 -0
- package/static/font/4608-4863.pbf +0 -0
- package/static/font/46080-46335.pbf +0 -0
- package/static/font/46336-46591.pbf +0 -0
- package/static/font/46592-46847.pbf +0 -0
- package/static/font/46848-47103.pbf +0 -0
- package/static/font/47104-47359.pbf +0 -0
- package/static/font/47360-47615.pbf +0 -0
- package/static/font/47616-47871.pbf +0 -0
- package/static/font/47872-48127.pbf +0 -0
- package/static/font/48128-48383.pbf +0 -0
- package/static/font/48384-48639.pbf +0 -0
- package/static/font/4864-5119.pbf +0 -0
- package/static/font/48640-48895.pbf +0 -0
- package/static/font/48896-49151.pbf +0 -0
- package/static/font/49152-49407.pbf +0 -0
- package/static/font/49408-49663.pbf +0 -0
- package/static/font/49664-49919.pbf +0 -0
- package/static/font/49920-50175.pbf +0 -0
- package/static/font/50176-50431.pbf +0 -0
- package/static/font/50432-50687.pbf +0 -0
- package/static/font/50688-50943.pbf +0 -0
- package/static/font/50944-51199.pbf +0 -0
- package/static/font/512-767.pbf +0 -0
- package/static/font/5120-5375.pbf +3 -0
- package/static/font/51200-51455.pbf +0 -0
- package/static/font/51456-51711.pbf +0 -0
- package/static/font/51712-51967.pbf +0 -0
- package/static/font/51968-52223.pbf +0 -0
- package/static/font/52224-52479.pbf +0 -0
- package/static/font/52480-52735.pbf +0 -0
- package/static/font/52736-52991.pbf +0 -0
- package/static/font/52992-53247.pbf +0 -0
- package/static/font/53248-53503.pbf +0 -0
- package/static/font/53504-53759.pbf +0 -0
- package/static/font/5376-5631.pbf +3 -0
- package/static/font/53760-54015.pbf +0 -0
- package/static/font/54016-54271.pbf +0 -0
- package/static/font/54272-54527.pbf +0 -0
- package/static/font/54528-54783.pbf +0 -0
- package/static/font/54784-55039.pbf +0 -0
- package/static/font/55040-55295.pbf +0 -0
- package/static/font/55296-55551.pbf +3 -0
- package/static/font/55552-55807.pbf +3 -0
- package/static/font/55808-56063.pbf +3 -0
- package/static/font/56064-56319.pbf +3 -0
- package/static/font/5632-5887.pbf +3 -0
- package/static/font/56320-56575.pbf +3 -0
- package/static/font/56576-56831.pbf +3 -0
- package/static/font/56832-57087.pbf +3 -0
- package/static/font/57088-57343.pbf +3 -0
- package/static/font/57344-57599.pbf +3 -0
- package/static/font/57600-57855.pbf +3 -0
- package/static/font/57856-58111.pbf +3 -0
- package/static/font/58112-58367.pbf +3 -0
- package/static/font/58368-58623.pbf +3 -0
- package/static/font/58624-58879.pbf +3 -0
- package/static/font/5888-6143.pbf +0 -0
- package/static/font/58880-59135.pbf +3 -0
- package/static/font/59136-59391.pbf +3 -0
- package/static/font/59392-59647.pbf +3 -0
- package/static/font/59648-59903.pbf +3 -0
- package/static/font/59904-60159.pbf +3 -0
- package/static/font/60160-60415.pbf +3 -0
- package/static/font/60416-60671.pbf +3 -0
- package/static/font/60672-60927.pbf +3 -0
- package/static/font/60928-61183.pbf +3 -0
- package/static/font/61184-61439.pbf +3 -0
- package/static/font/6144-6399.pbf +0 -0
- package/static/font/61440-61695.pbf +3 -0
- package/static/font/61696-61951.pbf +3 -0
- package/static/font/61952-62207.pbf +3 -0
- package/static/font/62208-62463.pbf +3 -0
- package/static/font/62464-62719.pbf +3 -0
- package/static/font/62720-62975.pbf +3 -0
- package/static/font/62976-63231.pbf +3 -0
- package/static/font/63232-63487.pbf +3 -0
- package/static/font/63488-63743.pbf +3 -0
- package/static/font/63744-63999.pbf +0 -0
- package/static/font/6400-6655.pbf +0 -0
- package/static/font/64000-64255.pbf +0 -0
- package/static/font/64256-64511.pbf +0 -0
- package/static/font/64512-64767.pbf +0 -0
- package/static/font/64768-65023.pbf +0 -0
- package/static/font/65024-65279.pbf +0 -0
- package/static/font/65280-65535.pbf +0 -0
- package/static/font/6656-6911.pbf +3 -0
- package/static/font/6912-7167.pbf +0 -0
- package/static/font/7168-7423.pbf +0 -0
- package/static/font/7424-7679.pbf +0 -0
- package/static/font/768-1023.pbf +0 -0
- package/static/font/7680-7935.pbf +0 -0
- package/static/font/7936-8191.pbf +0 -0
- package/static/font/8192-8447.pbf +0 -0
- package/static/font/8448-8703.pbf +0 -0
- package/static/font/8704-8959.pbf +0 -0
- package/static/font/8960-9215.pbf +0 -0
- package/static/font/9216-9471.pbf +0 -0
- package/static/font/9472-9727.pbf +0 -0
- package/static/font/9728-9983.pbf +0 -0
- package/static/font/9984-10239.pbf +0 -0
- package/static/index.html +59 -0
- package/static/logo.png +0 -0
- package/static/logo.svg +78 -0
- package/static/mapbox-gl-rtl-text@0.2.3.js +9851 -0
- package/static/minimal.js +9 -0
- package/static/minimal.json +7 -0
- package/static/sprites/maki.json +1706 -0
- package/static/sprites/maki.license +116 -0
- package/static/sprites/maki.png +0 -0
- package/static/sprites/maki@2x.json +1706 -0
- package/static/sprites/maki@2x.png +0 -0
- package/static/sprites/temaki.json +4306 -0
- package/static/sprites/temaki.license +118 -0
- package/static/sprites/temaki.png +0 -0
- package/static/sprites/temaki@2x.json +4306 -0
- package/static/sprites/temaki@2x.png +0 -0
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import equal from "deep-equal";
|
|
2
|
+
import bbox from "@turf/bbox";
|
|
3
|
+
import pick from "lodash.pick";
|
|
4
|
+
import { h } from "../lib/dom.js";
|
|
5
|
+
import { setBaseStyle } from "../lib/style.js";
|
|
6
|
+
import { setSetting, parseSettings } from "../lib/settings.js";
|
|
7
|
+
import {
|
|
8
|
+
getAutoRunFromQueryParams,
|
|
9
|
+
getOptionsFromQueryParams,
|
|
10
|
+
getQueryFromQueryParams,
|
|
11
|
+
toQueryParams,
|
|
12
|
+
} from "../lib/queryParams.js";
|
|
13
|
+
import {
|
|
14
|
+
localStorage,
|
|
15
|
+
optionsFromStorage,
|
|
16
|
+
queryFromStorage,
|
|
17
|
+
} from "../lib/localStorage.js";
|
|
18
|
+
import { UltraMap } from "./ultra-map.js";
|
|
19
|
+
|
|
20
|
+
const style = new CSSStyleSheet();
|
|
21
|
+
style.replaceSync(`
|
|
22
|
+
:host {
|
|
23
|
+
height: 100%;
|
|
24
|
+
width: 100%;
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-direction: column;
|
|
27
|
+
}
|
|
28
|
+
main {
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: row;
|
|
31
|
+
flex-grow: 1;
|
|
32
|
+
}
|
|
33
|
+
code-editor {
|
|
34
|
+
width: 45%;
|
|
35
|
+
border: none;
|
|
36
|
+
border-right: 1px solid #8f8f9d;
|
|
37
|
+
resize: horizontal;
|
|
38
|
+
overflow: auto;
|
|
39
|
+
}
|
|
40
|
+
ultra-map {
|
|
41
|
+
flex-grow: 1;
|
|
42
|
+
height: 100%;
|
|
43
|
+
}
|
|
44
|
+
@media (max-width: 900px) {
|
|
45
|
+
main {
|
|
46
|
+
flex-direction: column;
|
|
47
|
+
}
|
|
48
|
+
code-editor {
|
|
49
|
+
width: auto;
|
|
50
|
+
height: 45%;
|
|
51
|
+
resize: vertical;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
code-editor.fs {
|
|
55
|
+
display: none;
|
|
56
|
+
}
|
|
57
|
+
.fs style-picker,
|
|
58
|
+
.fs share-button,
|
|
59
|
+
.fs help-modal,
|
|
60
|
+
.fs download-button {
|
|
61
|
+
display: none;
|
|
62
|
+
}
|
|
63
|
+
.fs run-button {
|
|
64
|
+
z-index: 1;
|
|
65
|
+
display: block;
|
|
66
|
+
position: fixed;
|
|
67
|
+
top: 4px;
|
|
68
|
+
left: 4px;
|
|
69
|
+
}
|
|
70
|
+
fs-button {
|
|
71
|
+
z-index: 1;
|
|
72
|
+
position: fixed;
|
|
73
|
+
top: 4px;
|
|
74
|
+
right: 4px;
|
|
75
|
+
}
|
|
76
|
+
:host(:fullscreen) code-editor, :host(:fullscreen) nav-bar {
|
|
77
|
+
display: none;
|
|
78
|
+
}
|
|
79
|
+
run-button, download-button, share-button, style-picker, help-modal {
|
|
80
|
+
margin-right: 4px;
|
|
81
|
+
}
|
|
82
|
+
`);
|
|
83
|
+
|
|
84
|
+
export class UltraIDE extends HTMLElement {
|
|
85
|
+
autoRun = false;
|
|
86
|
+
query = "";
|
|
87
|
+
settings = {};
|
|
88
|
+
styles = [];
|
|
89
|
+
title = "Ultra";
|
|
90
|
+
icon = "/logo.svg";
|
|
91
|
+
help;
|
|
92
|
+
|
|
93
|
+
static MAP_INIT_SETTINGS = [
|
|
94
|
+
"options",
|
|
95
|
+
"controls",
|
|
96
|
+
"mapStyle",
|
|
97
|
+
"extraQueryProviders",
|
|
98
|
+
"persistState",
|
|
99
|
+
];
|
|
100
|
+
static props = ["settings", "query", "styles", "title", "icon", "help"];
|
|
101
|
+
|
|
102
|
+
constructor() {
|
|
103
|
+
super();
|
|
104
|
+
// Bind methods
|
|
105
|
+
this.onClickRun = this.onClickRun.bind(this);
|
|
106
|
+
this.onClickAbort = this.onClickAbort.bind(this);
|
|
107
|
+
this.resetMap = this.resetMap.bind(this);
|
|
108
|
+
this.onAuxClickRun = this.onAuxClickRun.bind(this);
|
|
109
|
+
this.onChangeCode = this.onChangeCode.bind(this);
|
|
110
|
+
this.onMoveEnd = this.onMoveEnd.bind(this);
|
|
111
|
+
this.onChangeStyle = this.onChangeStyle.bind(this);
|
|
112
|
+
this.onEnterFullscreen = this.onEnterFullscreen.bind(this);
|
|
113
|
+
this.onExitFullscreen = this.onExitFullscreen.bind(this);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
connectedCallback() {
|
|
117
|
+
// Create & populate Shadow DOM
|
|
118
|
+
const shadow = this.attachShadow({ mode: "open" });
|
|
119
|
+
shadow.adoptedStyleSheets.push(style);
|
|
120
|
+
shadow.appendChild(
|
|
121
|
+
h(
|
|
122
|
+
"nav-bar",
|
|
123
|
+
{ title: this.title, icon: this.icon },
|
|
124
|
+
h("fs-button", { slot: "fs-button" }),
|
|
125
|
+
h(
|
|
126
|
+
"span",
|
|
127
|
+
{ slot: "buttons" },
|
|
128
|
+
h("run-button"),
|
|
129
|
+
h("download-button"),
|
|
130
|
+
h("share-button"),
|
|
131
|
+
h("style-picker", { styles: this.styles }),
|
|
132
|
+
h("help-modal", this.help ? { help: this.help } : {}),
|
|
133
|
+
),
|
|
134
|
+
),
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
// Get initial query and center&zoom
|
|
138
|
+
this.query = getQueryFromQueryParams() || queryFromStorage() || this.query;
|
|
139
|
+
this.autoRun = getAutoRunFromQueryParams();
|
|
140
|
+
this.settings = { persistState: true, ...this.settings };
|
|
141
|
+
|
|
142
|
+
shadow.appendChild(
|
|
143
|
+
h(
|
|
144
|
+
"main",
|
|
145
|
+
{},
|
|
146
|
+
h("code-editor", {
|
|
147
|
+
autofocus: true,
|
|
148
|
+
source: this.query.then ? "" : this.query,
|
|
149
|
+
}),
|
|
150
|
+
h("ultra-map", pick(this.settings, UltraIDE.MAP_INIT_SETTINGS)),
|
|
151
|
+
),
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
this.refs = {
|
|
155
|
+
navBar: shadow.querySelector("nav-bar"),
|
|
156
|
+
codeEditor: shadow.querySelector("code-editor"),
|
|
157
|
+
mapLibre: shadow.querySelector("ultra-map"),
|
|
158
|
+
runButton: shadow.querySelector("run-button"),
|
|
159
|
+
downloadButton: shadow.querySelector("download-button"),
|
|
160
|
+
shareButton: shadow.querySelector("share-button"),
|
|
161
|
+
stylePicker: shadow.querySelector("style-picker"),
|
|
162
|
+
fsButton: shadow.querySelector("fs-button"),
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// Setup Event Listeners
|
|
166
|
+
this.refs.codeEditor.addEventListener("change", this.onChangeCode);
|
|
167
|
+
this.refs.runButton.addEventListener("run", this.onClickRun);
|
|
168
|
+
this.refs.codeEditor.addEventListener("run", this.onClickRun);
|
|
169
|
+
this.refs.runButton.addEventListener("auxclick", this.onAuxClickRun);
|
|
170
|
+
this.refs.runButton.addEventListener("abort", this.onClickAbort);
|
|
171
|
+
this.refs.stylePicker.addEventListener("change", this.onChangeStyle);
|
|
172
|
+
this.refs.fsButton.addEventListener(
|
|
173
|
+
"enter-fullscreen",
|
|
174
|
+
this.onEnterFullscreen,
|
|
175
|
+
);
|
|
176
|
+
this.refs.fsButton.addEventListener(
|
|
177
|
+
"exit-fullscreen",
|
|
178
|
+
this.onExitFullscreen,
|
|
179
|
+
);
|
|
180
|
+
this.refs.mapLibre.map.on("moveend", this.onMoveEnd);
|
|
181
|
+
this.refs.mapLibre.map.once("idle", this.onMoveEnd);
|
|
182
|
+
|
|
183
|
+
// initialize share values
|
|
184
|
+
this.refs.shareButton.query = this.query;
|
|
185
|
+
|
|
186
|
+
// set query when resolved if a promise
|
|
187
|
+
if (this.query.then) {
|
|
188
|
+
this.query.then((query) => {
|
|
189
|
+
this.refs.codeEditor.source = query;
|
|
190
|
+
this.refs.shareButton.query = this.query;
|
|
191
|
+
if (this.autoRun) {
|
|
192
|
+
this.onClickRun();
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
} else if (this.autoRun) {
|
|
196
|
+
this.onClickRun();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
async onClickRun() {
|
|
201
|
+
this.refs.runButton.loading = true; // Loading button state
|
|
202
|
+
this.resetMap(); // clear settings from previous run
|
|
203
|
+
try {
|
|
204
|
+
// basic query/option parsing
|
|
205
|
+
const settings = {
|
|
206
|
+
...this.settings,
|
|
207
|
+
...parseSettings(this.query),
|
|
208
|
+
};
|
|
209
|
+
Object.assign(this.refs.mapLibre, {
|
|
210
|
+
...pick(settings, UltraMap.RUNTIME_SETTINGS),
|
|
211
|
+
mapStyle: setBaseStyle(settings.mapStyle, this.settings.mapStyle),
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
this.refs.downloadButton.data = null;
|
|
215
|
+
this.controller = new AbortController();
|
|
216
|
+
this.refs.downloadButton.data = await this.refs.mapLibre.run(
|
|
217
|
+
this.controller,
|
|
218
|
+
);
|
|
219
|
+
delete this.controller;
|
|
220
|
+
|
|
221
|
+
this.refs.runButton.loading = false;
|
|
222
|
+
} catch (err) {
|
|
223
|
+
this.resetMap();
|
|
224
|
+
this.refs.mapLibre.run();
|
|
225
|
+
this.refs.runButton.loading = false;
|
|
226
|
+
if (err.name != "AbortError") {
|
|
227
|
+
alert(err);
|
|
228
|
+
throw err;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
onClickAbort() {
|
|
233
|
+
if (this.controller) {
|
|
234
|
+
this.controller.abort();
|
|
235
|
+
delete this.controller;
|
|
236
|
+
}
|
|
237
|
+
this.resetMap();
|
|
238
|
+
this.refs.mapLibre.run();
|
|
239
|
+
this.refs.runButton.loading = false;
|
|
240
|
+
}
|
|
241
|
+
resetMap() {
|
|
242
|
+
Object.assign(
|
|
243
|
+
this.refs.mapLibre,
|
|
244
|
+
pick(
|
|
245
|
+
{
|
|
246
|
+
...UltraMap.defaults,
|
|
247
|
+
mapStyle: this.settings.mapStyle || UltraMap.defaults.mapStyle,
|
|
248
|
+
},
|
|
249
|
+
UltraMap.RUNTIME_SETTINGS,
|
|
250
|
+
),
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
async onAuxClickRun() {
|
|
254
|
+
const params = { query: this.query, mode: "map" };
|
|
255
|
+
const settings = parseSettings(this.query);
|
|
256
|
+
if (
|
|
257
|
+
(settings.options?.center === undefined ||
|
|
258
|
+
settings.options?.zoom === undefined) &&
|
|
259
|
+
settings.options?.bounds === undefined
|
|
260
|
+
) {
|
|
261
|
+
params.center = this.refs.mapLibre.center.toArray();
|
|
262
|
+
params.zoom = this.refs.mapLibre.zoom;
|
|
263
|
+
}
|
|
264
|
+
window.location = toQueryParams(params);
|
|
265
|
+
}
|
|
266
|
+
onChangeCode() {
|
|
267
|
+
this.query = this.refs.codeEditor.source;
|
|
268
|
+
this.refs.shareButton.query = this.query;
|
|
269
|
+
localStorage.setItem("query", this.query);
|
|
270
|
+
}
|
|
271
|
+
onMoveEnd() {
|
|
272
|
+
const zoom = this.refs.mapLibre.zoom;
|
|
273
|
+
const center = this.refs.mapLibre.center.toArray();
|
|
274
|
+
this.refs.shareButton.zoom = zoom;
|
|
275
|
+
this.refs.shareButton.center = center;
|
|
276
|
+
}
|
|
277
|
+
onChangeStyle(e) {
|
|
278
|
+
this.refs.codeEditor.source = setSetting(this.query, {
|
|
279
|
+
style: e.detail.value,
|
|
280
|
+
});
|
|
281
|
+
const settings = parseSettings(this.query);
|
|
282
|
+
this.refs.mapLibre.mapStyle = setBaseStyle(
|
|
283
|
+
settings.mapStyle,
|
|
284
|
+
this.settings.mapStyle,
|
|
285
|
+
);
|
|
286
|
+
this.refs.mapLibre.run();
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
onEnterFullscreen() {
|
|
290
|
+
this.refs.navBar.classList.add("fs");
|
|
291
|
+
this.refs.codeEditor.classList.add("fs");
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
onExitFullscreen() {
|
|
295
|
+
this.refs.navBar.classList.remove("fs");
|
|
296
|
+
this.refs.codeEditor.classList.remove("fs");
|
|
297
|
+
}
|
|
298
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { h } from "../lib/dom.js";
|
|
2
|
+
import {
|
|
3
|
+
getConfigFromQueryParams,
|
|
4
|
+
getModeFromQueryParams,
|
|
5
|
+
} from "../lib/queryParams.js";
|
|
6
|
+
import { UltraMap } from "./ultra-map.js";
|
|
7
|
+
import { UltraIDE } from "./ultra-ide.js";
|
|
8
|
+
import pick from "lodash.pick";
|
|
9
|
+
|
|
10
|
+
import { defaultMode, modes } from "ultra-config";
|
|
11
|
+
|
|
12
|
+
const style = new CSSStyleSheet();
|
|
13
|
+
style.replaceSync(`
|
|
14
|
+
:host {
|
|
15
|
+
height: 100%;
|
|
16
|
+
width: 100%;
|
|
17
|
+
display: flex;
|
|
18
|
+
}
|
|
19
|
+
`);
|
|
20
|
+
|
|
21
|
+
export class UltraLoader extends HTMLElement {
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async connectedCallback() {
|
|
27
|
+
const shadow = this.attachShadow({ mode: "open" });
|
|
28
|
+
shadow.adoptedStyleSheets.push(style);
|
|
29
|
+
|
|
30
|
+
let mode = getModeFromQueryParams() || defaultMode;
|
|
31
|
+
let config = modes[mode];
|
|
32
|
+
|
|
33
|
+
const remoteConfig = await getConfigFromQueryParams();
|
|
34
|
+
if (remoteConfig) {
|
|
35
|
+
mode = getModeFromQueryParams() || remoteConfig.defaultMode;
|
|
36
|
+
config = remoteConfig.modes[mode];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (config.title) {
|
|
40
|
+
document.title = config.title;
|
|
41
|
+
}
|
|
42
|
+
if (config.icon) {
|
|
43
|
+
document.head.querySelector("link[rel=icon]").href = config.icon;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (mode === "map") {
|
|
47
|
+
shadow.appendChild(
|
|
48
|
+
h(
|
|
49
|
+
"ultra-map",
|
|
50
|
+
pick(config.settings, [
|
|
51
|
+
...UltraMap.INIT_SETTINGS,
|
|
52
|
+
...UltraMap.CONFIG_SETTINGS,
|
|
53
|
+
]),
|
|
54
|
+
),
|
|
55
|
+
);
|
|
56
|
+
} else {
|
|
57
|
+
shadow.appendChild(h("ultra-ide", pick(config, UltraIDE.props)));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import pick from "lodash.pick";
|
|
2
|
+
import bbox from "@turf/bbox";
|
|
3
|
+
import { h } from "../lib/dom.js";
|
|
4
|
+
import { setQueryBounds } from "../lib/bounds.js";
|
|
5
|
+
import { setBaseStyle } from "../lib/style.js";
|
|
6
|
+
import { parseSettings } from "../lib/settings.js";
|
|
7
|
+
import queryProviders from "../lib/queryProviders/index.js";
|
|
8
|
+
import AutoProvider from "../lib/queryProviders/auto.js";
|
|
9
|
+
import {
|
|
10
|
+
getOptionsFromQueryParams,
|
|
11
|
+
getQueryFromQueryParams,
|
|
12
|
+
} from "../lib/queryParams.js";
|
|
13
|
+
import { getStyle } from "../lib/style.js";
|
|
14
|
+
import { handleStyleImageMissing } from "../lib/sprites.js";
|
|
15
|
+
import { handleMouseClick, handleMouseMove } from "../lib/queryMap.js";
|
|
16
|
+
import { localStorage, optionsFromStorage } from "../lib/localStorage.js";
|
|
17
|
+
|
|
18
|
+
const css = new CSSStyleSheet();
|
|
19
|
+
css.replaceSync(`
|
|
20
|
+
:host, main {
|
|
21
|
+
height: 100%;
|
|
22
|
+
width: 100%;
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
}
|
|
26
|
+
`);
|
|
27
|
+
|
|
28
|
+
export class UltraMap extends HTMLElement {
|
|
29
|
+
#run;
|
|
30
|
+
#init;
|
|
31
|
+
#shadow;
|
|
32
|
+
|
|
33
|
+
#cachedType;
|
|
34
|
+
#cachedQuery;
|
|
35
|
+
#cachedSource;
|
|
36
|
+
|
|
37
|
+
#autoProvider;
|
|
38
|
+
|
|
39
|
+
static defaults = {
|
|
40
|
+
loadSettingsFromQueryParams: false,
|
|
41
|
+
type: "auto",
|
|
42
|
+
query: "",
|
|
43
|
+
server: null,
|
|
44
|
+
mapStyle: "https://demotiles.maplibre.org/style.json",
|
|
45
|
+
popupTemplate: null,
|
|
46
|
+
querySources: ["ultra"],
|
|
47
|
+
options: {},
|
|
48
|
+
controls: [],
|
|
49
|
+
fitBounds: false,
|
|
50
|
+
extraQueryProviders: {},
|
|
51
|
+
persistState: false,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
loadSettingsFromQueryParams = UltraMap.defaults.loadSettingsFromQueryParams;
|
|
55
|
+
|
|
56
|
+
type = UltraMap.defaults.type;
|
|
57
|
+
query = UltraMap.defaults.query;
|
|
58
|
+
server = UltraMap.defaults.server;
|
|
59
|
+
|
|
60
|
+
mapStyle = UltraMap.defaults.mapStyle;
|
|
61
|
+
|
|
62
|
+
popupTemplate = UltraMap.defaults.popupTemplate;
|
|
63
|
+
querySources = UltraMap.defaults.querySources;
|
|
64
|
+
|
|
65
|
+
options = UltraMap.defaults.options;
|
|
66
|
+
controls = UltraMap.defaults.controls;
|
|
67
|
+
|
|
68
|
+
fitBounds = UltraMap.defaults.fitBounds;
|
|
69
|
+
|
|
70
|
+
persistState = UltraMap.defaults.persistState;
|
|
71
|
+
|
|
72
|
+
extraQueryProviders = UltraMap.defaults.extraQueryProviders;
|
|
73
|
+
|
|
74
|
+
static CONFIG_SETTINGS = [
|
|
75
|
+
"extraQueryProviders",
|
|
76
|
+
"loadSettingsFromQueryParams",
|
|
77
|
+
"persistState",
|
|
78
|
+
];
|
|
79
|
+
static INIT_SETTINGS = [
|
|
80
|
+
"options",
|
|
81
|
+
"controls",
|
|
82
|
+
"type",
|
|
83
|
+
"server",
|
|
84
|
+
"popupTemplate",
|
|
85
|
+
"querySources",
|
|
86
|
+
"query",
|
|
87
|
+
"fitBounds",
|
|
88
|
+
"mapStyle",
|
|
89
|
+
];
|
|
90
|
+
static RUNTIME_SETTINGS = [
|
|
91
|
+
"type",
|
|
92
|
+
"server",
|
|
93
|
+
"popupTemplate",
|
|
94
|
+
"querySources",
|
|
95
|
+
"query",
|
|
96
|
+
"fitBounds",
|
|
97
|
+
"mapStyle",
|
|
98
|
+
];
|
|
99
|
+
|
|
100
|
+
constructor() {
|
|
101
|
+
super();
|
|
102
|
+
this.#run = this.#runUnbound.bind(this);
|
|
103
|
+
this.run = this.run.bind(this);
|
|
104
|
+
this.#init = this.#initUnbound.bind(this);
|
|
105
|
+
this.onMoveEnd = this.onMoveEnd.bind(this);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
get map() {
|
|
109
|
+
return this.refs?.mapLibre?.map;
|
|
110
|
+
}
|
|
111
|
+
get zoom() {
|
|
112
|
+
return this.refs?.mapLibre?.zoom;
|
|
113
|
+
}
|
|
114
|
+
get center() {
|
|
115
|
+
return this.refs?.mapLibre?.center;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
connectedCallback() {
|
|
119
|
+
this.#shadow = this.attachShadow({ mode: "open" });
|
|
120
|
+
this.#shadow.adoptedStyleSheets.push(css);
|
|
121
|
+
|
|
122
|
+
if (this.loadSettingsFromQueryParams) {
|
|
123
|
+
return Promise.resolve(getQueryFromQueryParams() || config.query).then(
|
|
124
|
+
async (query) => {
|
|
125
|
+
const querySettings = parseSettings(query);
|
|
126
|
+
const settings = {
|
|
127
|
+
...this,
|
|
128
|
+
...querySettings,
|
|
129
|
+
options: {
|
|
130
|
+
...this.options,
|
|
131
|
+
...querySettings.options,
|
|
132
|
+
...(this.persistState ? optionsFromStorage() : {}),
|
|
133
|
+
...getOptionsFromQueryParams(),
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
Object.assign(this, {
|
|
137
|
+
...pick(settings, [
|
|
138
|
+
...UltraMap.INIT_SETTINGS,
|
|
139
|
+
...UltraMap.RUNTIME_SETTINGS,
|
|
140
|
+
]),
|
|
141
|
+
mapStyle: setBaseStyle(settings.mapStyle, this.mapStyle),
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
return this.#init(await getStyle(this.mapStyle));
|
|
145
|
+
},
|
|
146
|
+
);
|
|
147
|
+
} else if (this.persistState) {
|
|
148
|
+
this.options = {
|
|
149
|
+
...this.options,
|
|
150
|
+
...optionsFromStorage(),
|
|
151
|
+
...getOptionsFromQueryParams(),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (!this.mapStyle || typeof this.mapStyle === "string") {
|
|
156
|
+
return this.#init(this.mapStyle);
|
|
157
|
+
} else {
|
|
158
|
+
return getStyle(this.mapStyle).then(this.#init);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
#initUnbound(mapStyle) {
|
|
163
|
+
this.refs = {
|
|
164
|
+
mapLibre: h("map-libre", {
|
|
165
|
+
mapStyle,
|
|
166
|
+
options: this.options,
|
|
167
|
+
controls: this.controls,
|
|
168
|
+
}),
|
|
169
|
+
};
|
|
170
|
+
this.#shadow.appendChild(h("main", {}, this.refs.mapLibre));
|
|
171
|
+
|
|
172
|
+
this.refs.mapLibre.map.on("click", (e) =>
|
|
173
|
+
handleMouseClick(
|
|
174
|
+
e,
|
|
175
|
+
this.#popupTemplate,
|
|
176
|
+
this.#popupContextBuilder,
|
|
177
|
+
this.querySources,
|
|
178
|
+
),
|
|
179
|
+
);
|
|
180
|
+
this.refs.mapLibre.map.on("mousemove", (e) =>
|
|
181
|
+
handleMouseMove(e, this.#popupTemplate, this.querySources),
|
|
182
|
+
);
|
|
183
|
+
this.refs.mapLibre.map.on("styleimagemissing", handleStyleImageMissing);
|
|
184
|
+
this.refs.mapLibre.map.on("moveend", this.onMoveEnd);
|
|
185
|
+
this.refs.mapLibre.map.once("idle", this.onMoveEnd);
|
|
186
|
+
|
|
187
|
+
return this.#run().then((data) => {
|
|
188
|
+
if (
|
|
189
|
+
this.#fitBounds &&
|
|
190
|
+
!this.options.bounds &&
|
|
191
|
+
(this.options.zoom === undefined || !this.options.center)
|
|
192
|
+
) {
|
|
193
|
+
if (
|
|
194
|
+
this.#cachedSource?.type === "geojson" &&
|
|
195
|
+
typeof this.#cachedSource?.data === "object" &&
|
|
196
|
+
(this.#cachedSource.data.features?.length > 0 ||
|
|
197
|
+
this.#cachedSource.data.geometry)
|
|
198
|
+
) {
|
|
199
|
+
this.refs.mapLibre.map.fitBounds(
|
|
200
|
+
bbox(this.#cachedSource.data),
|
|
201
|
+
typeof this.#fitBounds === "object"
|
|
202
|
+
? this.#fitBounds
|
|
203
|
+
: { padding: 100, maxZoom: 17, animate: false },
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return data;
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
async run(controller) {
|
|
212
|
+
this.refs.mapLibre.mapStyle = await getStyle(this.mapStyle);
|
|
213
|
+
const data = await this.#run(controller);
|
|
214
|
+
if (this.#fitBounds) {
|
|
215
|
+
if (
|
|
216
|
+
this.#cachedSource?.type === "geojson" &&
|
|
217
|
+
typeof this.#cachedSource?.data === "object" &&
|
|
218
|
+
(this.#cachedSource.data.features?.length > 0 ||
|
|
219
|
+
this.#cachedSource.data.geometry)
|
|
220
|
+
) {
|
|
221
|
+
this.refs.mapLibre.map.fitBounds(
|
|
222
|
+
bbox(this.#cachedSource.data),
|
|
223
|
+
typeof this.#fitBounds === "object"
|
|
224
|
+
? this.#fitBounds
|
|
225
|
+
: { padding: 100, maxZoom: 17, animate: false },
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return data;
|
|
230
|
+
}
|
|
231
|
+
async #runUnbound(controller) {
|
|
232
|
+
if (!this.query) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (!controller) {
|
|
237
|
+
controller = new AbortController();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const queryProvider = this.#queryProviders[this.type];
|
|
241
|
+
if (!queryProvider) {
|
|
242
|
+
throw new Error(`invalid query provider: ${this.type}`);
|
|
243
|
+
}
|
|
244
|
+
const query = setQueryBounds(this.query, this.refs.mapLibre.bounds);
|
|
245
|
+
if (
|
|
246
|
+
!this.#cachedSource ||
|
|
247
|
+
this.type !== this.#cachedType ||
|
|
248
|
+
query !== this.#cachedQuery
|
|
249
|
+
) {
|
|
250
|
+
this.#cachedQuery = query;
|
|
251
|
+
this.#cachedType = this.type;
|
|
252
|
+
this.#cachedSource = await queryProvider.source(query, controller, {
|
|
253
|
+
server: this.server,
|
|
254
|
+
bounds: this.refs.mapLibre.bounds,
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
this.refs.mapLibre.mapStyle = await getStyle(this.mapStyle, {
|
|
258
|
+
// Don't love this...
|
|
259
|
+
source: this.#cachedSource,
|
|
260
|
+
layers: queryProvider.layers ? queryProvider.layers("ultra") : [],
|
|
261
|
+
});
|
|
262
|
+
return this.#cachedSource.data;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
get #queryProviders() {
|
|
266
|
+
if (!this.#autoProvider) {
|
|
267
|
+
this.#autoProvider = new AutoProvider({
|
|
268
|
+
...queryProviders,
|
|
269
|
+
...this.extraQueryProviders,
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
return {
|
|
273
|
+
auto: this.#autoProvider,
|
|
274
|
+
...queryProviders,
|
|
275
|
+
...this.extraQueryProviders,
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
get #fitBounds() {
|
|
280
|
+
if (this.fitBounds) {
|
|
281
|
+
return this.fitBounds;
|
|
282
|
+
}
|
|
283
|
+
const queryProvider = this.#queryProviders[this.type];
|
|
284
|
+
if (queryProvider && queryProvider.fitBounds) {
|
|
285
|
+
return queryProvider.fitBounds;
|
|
286
|
+
}
|
|
287
|
+
return this.fitBounds;
|
|
288
|
+
}
|
|
289
|
+
get #popupTemplate() {
|
|
290
|
+
if (this.popupTemplate) {
|
|
291
|
+
return this.popupTemplate;
|
|
292
|
+
}
|
|
293
|
+
const queryProvider = this.#queryProviders[this.type];
|
|
294
|
+
if (queryProvider && queryProvider.popupTemplate) {
|
|
295
|
+
return queryProvider.popupTemplate;
|
|
296
|
+
}
|
|
297
|
+
return this.popupTemplate;
|
|
298
|
+
}
|
|
299
|
+
get #popupContextBuilder() {
|
|
300
|
+
const queryProvider = this.#queryProviders[this.type];
|
|
301
|
+
if (queryProvider && queryProvider.popupContextBuilder) {
|
|
302
|
+
return queryProvider.popupContextBuilder;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
onMoveEnd() {
|
|
307
|
+
const zoom = this.refs.mapLibre.zoom;
|
|
308
|
+
const center = this.refs.mapLibre.center.toArray();
|
|
309
|
+
localStorage.setItem("mapZoom", zoom);
|
|
310
|
+
localStorage.setItem("mapCenter", center);
|
|
311
|
+
}
|
|
312
|
+
}
|