@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,199 @@
|
|
|
1
|
+
import osmtogeojson from "osmtogeojson";
|
|
2
|
+
|
|
3
|
+
export const flattenProperties = (geoJSON) => {
|
|
4
|
+
geoJSON.features = geoJSON.features.map((x) => {
|
|
5
|
+
const properties = x.properties;
|
|
6
|
+
delete x.properties;
|
|
7
|
+
return {
|
|
8
|
+
properties: {
|
|
9
|
+
"@id": properties.id,
|
|
10
|
+
"@type": properties.type,
|
|
11
|
+
"@meta":
|
|
12
|
+
Object.keys(properties.meta).length > 0 ? properties.meta : undefined,
|
|
13
|
+
...properties.tags,
|
|
14
|
+
},
|
|
15
|
+
...x,
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
return geoJSON;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const popupTemplate = `
|
|
22
|
+
<h2>
|
|
23
|
+
{{ type }}
|
|
24
|
+
<a href="https://openstreetmap.org/{{ type }}/{{ id }}" target="_blank">{{ id }}</a>
|
|
25
|
+
<a href="https://openstreetmap.org/edit?{{ type }}={{ id }}" target="_blank">✏️</a>
|
|
26
|
+
</h2>
|
|
27
|
+
<h3>Properties</h3>
|
|
28
|
+
{%- for tag in tags %}
|
|
29
|
+
{%- if tag[0] contains "website" %}
|
|
30
|
+
<code>{{ tag[0] }} = <a href="{{ tag[1] }}" target="_blank">{{ tag[1] }}</a></code>
|
|
31
|
+
{%- elsif tag[0] contains "wikidata" %}
|
|
32
|
+
<code>{{ tag[0] }} = <a href="https://wikidata.org/wiki/{{ tag[1] }}" target="_blank">{{ tag[1] }}</a></code>
|
|
33
|
+
{%- elsif tag[0] contains "wikipedia" %}
|
|
34
|
+
{% assign lang = tag[1] | split: ":" | first %}
|
|
35
|
+
<code>{{ tag[0] }} = <a href="https://{{ lang }}.wikipedia.org/wiki/{{ tag[1] | replace_first: lang, "" | replace_first: ":", "" }}" target="_blank">{{ tag[1] }}</a></code>
|
|
36
|
+
{%- else %}
|
|
37
|
+
<code>{{ tag[0] }} = {{ tag[1] }}</code>
|
|
38
|
+
{%- endif %}
|
|
39
|
+
<br>
|
|
40
|
+
{%- endfor %}
|
|
41
|
+
{%- if meta %}
|
|
42
|
+
<h3>Meta</h3>
|
|
43
|
+
{%- for tag in meta %}
|
|
44
|
+
{%- if tag[0] == "changeset" %}
|
|
45
|
+
<code>{{ tag[0] }} = <a href="https://openstreetmap.org/changeset/{{ tag[1] }}" target="_blank">{{ tag[1] }}</a></code>
|
|
46
|
+
{%- elsif tag[0] == "user" %}
|
|
47
|
+
<code>{{ tag[0] }} = <a href="https://openstreetmap.org/user/{{ tag[1] }}" target="_blank">{{ tag[1] }}</a></code>
|
|
48
|
+
{%- else %}
|
|
49
|
+
<code>{{ tag[0] }} = {{ tag[1] }}</code>
|
|
50
|
+
{%- endif %}
|
|
51
|
+
<br>
|
|
52
|
+
{%- endfor %}
|
|
53
|
+
{%- endif %}
|
|
54
|
+
{%- if coordinates %}
|
|
55
|
+
<h3>Coordinates</h3>
|
|
56
|
+
<a href="geo://{{coordinates[1]}},{{coordinates[0]}}">{{coordinates[1] | round: 6 }} / {{coordinates[0] | round: 6 }}</a> <small>(lat/lon)</small>
|
|
57
|
+
{%- endif %}
|
|
58
|
+
`;
|
|
59
|
+
export const popupContextBuilder = ({ properties, geometry }) => {
|
|
60
|
+
const templateContext = {
|
|
61
|
+
id: properties["@id"],
|
|
62
|
+
type: properties["@type"],
|
|
63
|
+
meta: JSON.parse(properties["@meta"] || null),
|
|
64
|
+
tags: { ...properties },
|
|
65
|
+
};
|
|
66
|
+
delete templateContext.tags["@type"];
|
|
67
|
+
delete templateContext.tags["@id"];
|
|
68
|
+
delete templateContext.tags["@meta"];
|
|
69
|
+
if (properties["@type"] === "node") {
|
|
70
|
+
templateContext.coordinates = geometry.coordinates;
|
|
71
|
+
}
|
|
72
|
+
return templateContext;
|
|
73
|
+
};
|
|
74
|
+
export const layers = (source) => [
|
|
75
|
+
{
|
|
76
|
+
id: `${source}-polygons`,
|
|
77
|
+
type: "fill",
|
|
78
|
+
source,
|
|
79
|
+
filter: ["all", ["==", ["geometry-type"], "Polygon"]],
|
|
80
|
+
paint: {
|
|
81
|
+
"fill-color": "rgba(255, 204, 0, .5)",
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: `${source}-polygons-stroke`,
|
|
86
|
+
type: "line",
|
|
87
|
+
source,
|
|
88
|
+
filter: ["all", ["==", ["geometry-type"], "Polygon"]],
|
|
89
|
+
layout: { "line-join": "round", "line-cap": "round" },
|
|
90
|
+
paint: { "line-width": 2, "line-color": "rgba(0, 51, 255, 0.6)" },
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
id: `${source}-lines`,
|
|
94
|
+
type: "line",
|
|
95
|
+
source,
|
|
96
|
+
filter: ["all", ["==", ["geometry-type"], "LineString"]],
|
|
97
|
+
paint: {
|
|
98
|
+
"line-width": 5,
|
|
99
|
+
"line-color": "rgba(0, 51, 255, 0.6)",
|
|
100
|
+
},
|
|
101
|
+
layout: { "line-join": "round", "line-cap": "round" },
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
id: `${source}-points`,
|
|
105
|
+
type: "circle",
|
|
106
|
+
source,
|
|
107
|
+
filter: ["all", ["==", ["geometry-type"], "Point"]],
|
|
108
|
+
paint: {
|
|
109
|
+
"circle-stroke-width": 2,
|
|
110
|
+
"circle-stroke-color": "rgba(0, 51, 255, 0.6)",
|
|
111
|
+
"circle-color": "rgba(255, 204, 0, 0.6)",
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
];
|
|
115
|
+
|
|
116
|
+
async function osmxmlSource(query, controller) {
|
|
117
|
+
let doc = new window.DOMParser().parseFromString(query, "text/xml");
|
|
118
|
+
if (doc.querySelector("parsererror")) {
|
|
119
|
+
const resp = await fetch(query, { signal: controller.signal });
|
|
120
|
+
doc = new window.DOMParser().parseFromString(await resp.text(), "text/xml");
|
|
121
|
+
}
|
|
122
|
+
const data = flattenProperties(
|
|
123
|
+
osmtogeojson(doc, { verbose: true, flatProperties: false }),
|
|
124
|
+
);
|
|
125
|
+
return { type: "geojson", data, generateId: true };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
async function osmjsonSource(query, controller) {
|
|
129
|
+
let json;
|
|
130
|
+
try {
|
|
131
|
+
json = JSON.parse(query);
|
|
132
|
+
} catch {
|
|
133
|
+
const resp = await fetch(query, { signal: controller.signal });
|
|
134
|
+
json = await resp.json();
|
|
135
|
+
}
|
|
136
|
+
const data = flattenProperties(
|
|
137
|
+
osmtogeojson(json, { verbose: true, flatProperties: false }),
|
|
138
|
+
);
|
|
139
|
+
return {
|
|
140
|
+
type: "geojson",
|
|
141
|
+
data,
|
|
142
|
+
generateId: true,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// OSM XML & JSON are detected in 2 ways:
|
|
147
|
+
// URLs - they look like /api/0.6 URLs with node, way/full, or relation/full
|
|
148
|
+
// Local XML document with a top-level `osm` node
|
|
149
|
+
// Local JSON document with a top-level `version` key with a value of `0.6`
|
|
150
|
+
const osmApiRegex =
|
|
151
|
+
/^\/api\/0.6\/(node\/(\d+)|way\/(\d+)\/full|relation\/(\d+)\/full)(\.json)?/;
|
|
152
|
+
const detectXML = (query) => {
|
|
153
|
+
const doc = new window.DOMParser().parseFromString(query, "text/xml");
|
|
154
|
+
if (
|
|
155
|
+
!doc.querySelector("parsererror") &&
|
|
156
|
+
doc.childNodes[0].nodeName === "osm"
|
|
157
|
+
) {
|
|
158
|
+
return query;
|
|
159
|
+
}
|
|
160
|
+
try {
|
|
161
|
+
const url = new URL(query);
|
|
162
|
+
const match = url.pathname.match(osmApiRegex);
|
|
163
|
+
if (match && !match.slice(-1)[0]) {
|
|
164
|
+
return query;
|
|
165
|
+
}
|
|
166
|
+
} catch {}
|
|
167
|
+
};
|
|
168
|
+
const detectJSON = (query) => {
|
|
169
|
+
try {
|
|
170
|
+
const json = JSON.parse(query);
|
|
171
|
+
if (json.version === "0.6") {
|
|
172
|
+
return query;
|
|
173
|
+
}
|
|
174
|
+
} catch {}
|
|
175
|
+
try {
|
|
176
|
+
const url = new URL(query);
|
|
177
|
+
const match = url.pathname.match(osmApiRegex);
|
|
178
|
+
if (match && match.slice(-1)[0]) {
|
|
179
|
+
return query;
|
|
180
|
+
}
|
|
181
|
+
} catch {}
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
export const osmxml = {
|
|
185
|
+
source: osmxmlSource,
|
|
186
|
+
fitBounds: true,
|
|
187
|
+
layers,
|
|
188
|
+
popupTemplate,
|
|
189
|
+
popupContextBuilder,
|
|
190
|
+
detect: detectXML,
|
|
191
|
+
};
|
|
192
|
+
export const osmjson = {
|
|
193
|
+
source: osmjsonSource,
|
|
194
|
+
fitBounds: true,
|
|
195
|
+
layers,
|
|
196
|
+
popupTemplate,
|
|
197
|
+
popupContextBuilder,
|
|
198
|
+
detect: detectJSON,
|
|
199
|
+
};
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import osmtogeojson from "osmtogeojson";
|
|
2
|
+
import { setQueryBounds } from "../bounds.js";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
flattenProperties,
|
|
6
|
+
layers,
|
|
7
|
+
popupTemplate,
|
|
8
|
+
popupContextBuilder,
|
|
9
|
+
} from "./osm.js";
|
|
10
|
+
|
|
11
|
+
// Overpass queries are detected from common strings found in queries written in OverpassQL
|
|
12
|
+
const overpassQLRegexes = [
|
|
13
|
+
/\[bbox:{{bbox}}\]/,
|
|
14
|
+
/\({{bbox}}\)/,
|
|
15
|
+
/\[out:json\]/,
|
|
16
|
+
/\[out:xml\]/,
|
|
17
|
+
/node\[[^]\]/,
|
|
18
|
+
/way\[[^]\]/,
|
|
19
|
+
/relation\[[^]\]/,
|
|
20
|
+
/nwr\[[^]\]/,
|
|
21
|
+
/nw\[[^]\]/,
|
|
22
|
+
/nr\[[^]\]/,
|
|
23
|
+
/wr\[[^]\]/,
|
|
24
|
+
/area\[[^]\]/,
|
|
25
|
+
/node\([^)]\)/,
|
|
26
|
+
/way\([^)]\)/,
|
|
27
|
+
/relation\([^)]\)/,
|
|
28
|
+
/nwr\([^)]\)/,
|
|
29
|
+
/nw\([^)]\)/,
|
|
30
|
+
/nr\([^)]\)/,
|
|
31
|
+
/wr\([^)]\)/,
|
|
32
|
+
/area\([^)]\)/,
|
|
33
|
+
/out( geom| center| skel)?;/,
|
|
34
|
+
];
|
|
35
|
+
function detect(query) {
|
|
36
|
+
for (const re of overpassQLRegexes) {
|
|
37
|
+
if (query.match(re)) {
|
|
38
|
+
return query;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const overpass = {
|
|
44
|
+
source: async function (query, controller, { server }) {
|
|
45
|
+
if (!server) {
|
|
46
|
+
server = "https://overpass-api.de/api";
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
type: "geojson",
|
|
50
|
+
data: await callInterpreter(query, controller, server),
|
|
51
|
+
attribution:
|
|
52
|
+
'\u003Ca href="https://www.openstreetmap.org/copyright" target="_blank"\u003E© OpenStreetMap contributors\u003C/a\u003E',
|
|
53
|
+
generateId: true,
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
layers,
|
|
57
|
+
popupTemplate,
|
|
58
|
+
popupContextBuilder,
|
|
59
|
+
detect,
|
|
60
|
+
};
|
|
61
|
+
export default overpass;
|
|
62
|
+
|
|
63
|
+
export async function callInterpreter(
|
|
64
|
+
query,
|
|
65
|
+
controller,
|
|
66
|
+
apiRoot = "https://overpass-api.de/api",
|
|
67
|
+
) {
|
|
68
|
+
const resp = await fetch(apiRoot + "/interpreter", {
|
|
69
|
+
body: query,
|
|
70
|
+
method: "POST",
|
|
71
|
+
mode: "cors",
|
|
72
|
+
signal: controller.signal,
|
|
73
|
+
});
|
|
74
|
+
if (
|
|
75
|
+
resp.status == 200 &&
|
|
76
|
+
!resp.headers.get("content-type").startsWith("text/html")
|
|
77
|
+
) {
|
|
78
|
+
let geoJSON;
|
|
79
|
+
if (resp.headers.get("content-type") == "application/osm3s+xml") {
|
|
80
|
+
geoJSON = osmtogeojson(
|
|
81
|
+
new window.DOMParser().parseFromString(await resp.text(), "text/xml"),
|
|
82
|
+
{ flatProperties: false },
|
|
83
|
+
);
|
|
84
|
+
} else {
|
|
85
|
+
geoJSON = osmtogeojson(await resp.json(), { flatProperties: false });
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return flattenProperties(geoJSON);
|
|
89
|
+
} else {
|
|
90
|
+
const dom = new window.DOMParser().parseFromString(
|
|
91
|
+
await resp.text(),
|
|
92
|
+
"text/xml",
|
|
93
|
+
);
|
|
94
|
+
alert(
|
|
95
|
+
Array.from(dom.body.querySelectorAll("p"))
|
|
96
|
+
.slice(1)
|
|
97
|
+
.map((p) => p.textContent)
|
|
98
|
+
.join("\n"),
|
|
99
|
+
);
|
|
100
|
+
return { type: "FeatureCollection", features: [] };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const osmUrlRe = /^https:\/\/www.openstreetmap.org\/(node|way|relation)\/(\d+)/;
|
|
105
|
+
export const osmWebsite = {
|
|
106
|
+
...overpass,
|
|
107
|
+
source: async function (query, controller, { server, bounds }) {
|
|
108
|
+
const urlMatch = query.match(osmUrlRe);
|
|
109
|
+
if (urlMatch) {
|
|
110
|
+
const [type, id] = urlMatch.slice(1);
|
|
111
|
+
return overpass.source(`${type}(${id});out geom;`, controller, {
|
|
112
|
+
server,
|
|
113
|
+
bounds,
|
|
114
|
+
});
|
|
115
|
+
} else {
|
|
116
|
+
throw new Error(`Don't know how to load ${query}`);
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
detect: function (query) {
|
|
120
|
+
return !!query.match(osmUrlRe);
|
|
121
|
+
},
|
|
122
|
+
fitBounds: true,
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export const osmWiki = {
|
|
126
|
+
...overpass,
|
|
127
|
+
source: async function (query, controller, { server, bounds }) {
|
|
128
|
+
const url = new URL(query);
|
|
129
|
+
const page = decodeURIComponent(url.pathname.slice(6));
|
|
130
|
+
let overpassQuery;
|
|
131
|
+
if (page.split(":")[0] === "Tag") {
|
|
132
|
+
const [key, value] = page.split(":")[1].split("=");
|
|
133
|
+
overpassQuery = setQueryBounds(
|
|
134
|
+
`[bbox:{{bbox}}];
|
|
135
|
+
nwr["${key}"="${value}"];
|
|
136
|
+
out geom;`,
|
|
137
|
+
bounds,
|
|
138
|
+
);
|
|
139
|
+
} else if (page.split(":")[0] === "Key") {
|
|
140
|
+
overpassQuery = setQueryBounds(
|
|
141
|
+
`[bbox:{{bbox}}];
|
|
142
|
+
nwr["${page.split(":")[1]}"];
|
|
143
|
+
out geom;`,
|
|
144
|
+
bounds,
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (!overpassQuery) {
|
|
149
|
+
throw new Error(`Don't know how to load ${query}`);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return overpass.source(query, controller, { server, bounds });
|
|
153
|
+
},
|
|
154
|
+
detect: function (query, bounds) {
|
|
155
|
+
if (!query.startsWith("https://wiki.openstreetmap.org/wiki/")) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const url = new URL(query);
|
|
159
|
+
const page = decodeURIComponent(url.pathname.slice(6));
|
|
160
|
+
return page.split(":")[0] === "Tag" || page.split(":")[0] === "Key";
|
|
161
|
+
},
|
|
162
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const layers = (source) => [
|
|
2
|
+
{
|
|
3
|
+
id: `${source}-raster`,
|
|
4
|
+
type: "raster",
|
|
5
|
+
source,
|
|
6
|
+
},
|
|
7
|
+
];
|
|
8
|
+
export default {
|
|
9
|
+
source: (query) => {
|
|
10
|
+
const source = {
|
|
11
|
+
type: "raster",
|
|
12
|
+
tileSize: 256,
|
|
13
|
+
layers,
|
|
14
|
+
};
|
|
15
|
+
if (query.match(/{(x|y|z|bbox-epsg-3857)}/)) {
|
|
16
|
+
source.tiles = query.split("\n").filter((x) => !!x);
|
|
17
|
+
} else {
|
|
18
|
+
source.url = query.trim();
|
|
19
|
+
}
|
|
20
|
+
return source;
|
|
21
|
+
},
|
|
22
|
+
layers,
|
|
23
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { tcx } from "@tmcw/togeojson";
|
|
2
|
+
|
|
3
|
+
const layers = (source) => [
|
|
4
|
+
{
|
|
5
|
+
id: "ultra-tcx-line-casing",
|
|
6
|
+
type: "line",
|
|
7
|
+
source: "ultra",
|
|
8
|
+
layout: {
|
|
9
|
+
"line-cap": "round",
|
|
10
|
+
"line-join": "round",
|
|
11
|
+
},
|
|
12
|
+
paint: {
|
|
13
|
+
"line-color": "rgb(164, 112, 179)",
|
|
14
|
+
"line-opacity": 0.8,
|
|
15
|
+
"line-width": 2,
|
|
16
|
+
"line-gap-width": 5,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: "ultra-tcx-line",
|
|
21
|
+
type: "line",
|
|
22
|
+
source: "ultra",
|
|
23
|
+
layout: {
|
|
24
|
+
"line-cap": "round",
|
|
25
|
+
"line-join": "round",
|
|
26
|
+
},
|
|
27
|
+
paint: {
|
|
28
|
+
"line-color": "rgb(226, 126, 255)",
|
|
29
|
+
"line-opacity": 0.5,
|
|
30
|
+
"line-width": 5,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: `${source}-tcx-dir`,
|
|
35
|
+
type: "symbol",
|
|
36
|
+
source,
|
|
37
|
+
filter: ["==", ["geometry-type"], "LineString"],
|
|
38
|
+
layout: {
|
|
39
|
+
"symbol-placement": "line",
|
|
40
|
+
"symbol-spacing": 50,
|
|
41
|
+
"icon-image": "maki:triangle",
|
|
42
|
+
"icon-rotate": 90,
|
|
43
|
+
"icon-size": 0.3,
|
|
44
|
+
},
|
|
45
|
+
paint: {
|
|
46
|
+
"icon-color": "rgb(164, 112, 179)",
|
|
47
|
+
"icon-halo-color": "rgb(226, 126, 255)",
|
|
48
|
+
"icon-halo-width": 1,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
/*
|
|
52
|
+
{
|
|
53
|
+
id: `${source}-tcx-poi`,
|
|
54
|
+
type: "symbol",
|
|
55
|
+
source,
|
|
56
|
+
filter: ["==", ["geometry-type"], "Point"],
|
|
57
|
+
layout: {
|
|
58
|
+
"icon-overlap": "always",
|
|
59
|
+
"icon-size": 0.5,
|
|
60
|
+
"icon-anchor": "bottom",
|
|
61
|
+
"icon-image": ["concat", "https://corsproxy.io/?", ["get", "icon"]],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
*/
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
const detect = async (query) => {
|
|
68
|
+
try {
|
|
69
|
+
if (query.startsWith("https://")) {
|
|
70
|
+
const resp = await fetch(query, { cors: true });
|
|
71
|
+
if (resp.ok) {
|
|
72
|
+
query = await resp.text();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
} catch {}
|
|
76
|
+
const doc = new window.DOMParser().parseFromString(query, "text/xml");
|
|
77
|
+
if (
|
|
78
|
+
!doc.querySelector("parsererror") &&
|
|
79
|
+
doc.childNodes[0].nodeName === "TrainingCenterDatabase"
|
|
80
|
+
) {
|
|
81
|
+
return query;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export default {
|
|
86
|
+
source: async function (query, controller) {
|
|
87
|
+
let doc = new window.DOMParser().parseFromString(query, "text/xml");
|
|
88
|
+
if (doc.querySelector("parsererror")) {
|
|
89
|
+
const resp = await fetch(query.trim(), { signal: controller.signal });
|
|
90
|
+
doc = new window.DOMParser().parseFromString(
|
|
91
|
+
await resp.text(),
|
|
92
|
+
"text/xml",
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
const data = tcx(doc);
|
|
96
|
+
return { type: "geojson", data, generateId: true };
|
|
97
|
+
},
|
|
98
|
+
layers,
|
|
99
|
+
popupTemplate: `
|
|
100
|
+
<h2>{{properties.name}}</h2>
|
|
101
|
+
<p>{{properties.description}}</p>
|
|
102
|
+
`,
|
|
103
|
+
detect,
|
|
104
|
+
fitBounds: true,
|
|
105
|
+
};
|
package/lib/settings.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import YAML from "yaml";
|
|
2
|
+
|
|
3
|
+
const extractFrontMatter = (content) => {
|
|
4
|
+
if (!content) {
|
|
5
|
+
return { query: "", frontmatter: "" };
|
|
6
|
+
}
|
|
7
|
+
const result = /(^---\n((?<frontmatter>.*)\n)?---(\n|$))?(?<query>.*)?/s.exec(
|
|
8
|
+
content,
|
|
9
|
+
);
|
|
10
|
+
if (result) {
|
|
11
|
+
return {
|
|
12
|
+
query: result.groups.query?.trim() || "",
|
|
13
|
+
frontmatter: result.groups.frontmatter || "",
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
return { query: content?.trim() };
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const parseSettings = (query) => {
|
|
20
|
+
let frontmatter;
|
|
21
|
+
({ frontmatter, query } = extractFrontMatter(query));
|
|
22
|
+
let settings = {};
|
|
23
|
+
if (frontmatter) {
|
|
24
|
+
settings = YAML.parse(frontmatter, { merge: true }) || {};
|
|
25
|
+
const doc = YAML.parseDocument(frontmatter, undefined, {
|
|
26
|
+
merge: true,
|
|
27
|
+
});
|
|
28
|
+
if (doc.warnings.length > 0) {
|
|
29
|
+
alert(
|
|
30
|
+
"Warnings when parsing frontmatter:\n\n" +
|
|
31
|
+
doc.warnings.map(({ message }) => message).join("\n"),
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (query.trim()) {
|
|
36
|
+
settings.query = query.trim();
|
|
37
|
+
}
|
|
38
|
+
settings.mapStyle = settings.style;
|
|
39
|
+
delete settings.style;
|
|
40
|
+
return settings;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const setSetting = (query, { style, server }) => {
|
|
44
|
+
let frontmatter;
|
|
45
|
+
({ frontmatter, query } = extractFrontMatter(query));
|
|
46
|
+
let settingsStr = "";
|
|
47
|
+
if (style) {
|
|
48
|
+
settingsStr += `style: ${style}\n`;
|
|
49
|
+
}
|
|
50
|
+
if (server) {
|
|
51
|
+
settingsStr += `server: ${server}\n`;
|
|
52
|
+
}
|
|
53
|
+
if (frontmatter && frontmatter.trim()) {
|
|
54
|
+
const settings = YAML.parseDocument(frontmatter, undefined, {
|
|
55
|
+
merge: true,
|
|
56
|
+
});
|
|
57
|
+
if (style) {
|
|
58
|
+
const queryStyle = settings.get("style");
|
|
59
|
+
if (!queryStyle || typeof queryStyle === "string") {
|
|
60
|
+
settings.set("style", style);
|
|
61
|
+
} else {
|
|
62
|
+
queryStyle.set("extends", style);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (server) {
|
|
66
|
+
settings.set("server", server);
|
|
67
|
+
}
|
|
68
|
+
settingsStr = YAML.stringify(settings);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return `---\n${settingsStr}---\n${query}`;
|
|
72
|
+
};
|
package/lib/sprites.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const fetchedImages = {};
|
|
2
|
+
export const handleStyleImageMissing = async (ev) => {
|
|
3
|
+
const builtin = ev.id.match(/\/icons\/(maki|temaki)\/(.*)\.png/);
|
|
4
|
+
if (ev.id.startsWith("https://") || ev.id.startsWith("data:")) {
|
|
5
|
+
if (!fetchedImages[ev.id]) {
|
|
6
|
+
fetchedImages[ev.id] = true;
|
|
7
|
+
const image = await ev.target.loadImage(ev.id);
|
|
8
|
+
ev.target.addImage(ev.id, image.data);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
if (builtin) {
|
|
12
|
+
ev.target.addImage(
|
|
13
|
+
ev.id,
|
|
14
|
+
ev.target.getImage(builtin.slice(1, 3).join(":")).data,
|
|
15
|
+
{ sdf: true },
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
};
|