@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,104 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { parseSettings } from "./lib/settings.js";
|
|
4
|
+
|
|
5
|
+
function generateMarkdownForExample(config, file, queryContent, dir) {
|
|
6
|
+
const { title, description } = config;
|
|
7
|
+
const params = new URLSearchParams();
|
|
8
|
+
params.set("query", queryContent);
|
|
9
|
+
if (config.options?.center && config.options?.zoom !== undefined) {
|
|
10
|
+
params.set(
|
|
11
|
+
"m",
|
|
12
|
+
`${config.options.zoom}/${config.options.center[1]}/${config.options.center[0]}`,
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
let html = `
|
|
16
|
+
# ${title}
|
|
17
|
+
|
|
18
|
+
${description}
|
|
19
|
+
|
|
20
|
+
<iframe src="/#map&query=${encodeURIComponent(queryContent)}" width="100%" style="border:none; height:400px"></iframe>
|
|
21
|
+
|
|
22
|
+
\`\`\`
|
|
23
|
+
${queryContent}
|
|
24
|
+
\`\`\`
|
|
25
|
+
<br>
|
|
26
|
+
<a target="_blank" href="/#map&${params.toString()}">View Map on Overpass Ultra</a>
|
|
27
|
+
<br>
|
|
28
|
+
<a target="_blank" href="/#${params.toString()}">Edit Query on Overpass Ultra</a>`;
|
|
29
|
+
if (dir.startsWith("MapLibre-Examples"))
|
|
30
|
+
html += `<br>
|
|
31
|
+
<a target="_blank" href="https://maplibre.org/maplibre-gl-js/docs/examples/${file.replace(".ultra", "")}/">View MapLibre Example</a>
|
|
32
|
+
`;
|
|
33
|
+
return html;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function generateMarkdownIndexFileOfAllExamples(examplesFolder, indexArray) {
|
|
37
|
+
let indexMarkdown = "# Overview \n\n";
|
|
38
|
+
const indexMdFile = path.join(examplesFolder, "index.md");
|
|
39
|
+
if (fs.existsSync(indexMdFile)) {
|
|
40
|
+
indexMarkdown = fs.readFileSync(indexMdFile, "utf-8");
|
|
41
|
+
}
|
|
42
|
+
for (const indexArrayItem of indexArray) {
|
|
43
|
+
indexMarkdown += `
|
|
44
|
+
## [${indexArrayItem.title}](./${indexArrayItem.mdFileName})
|
|
45
|
+
|
|
46
|
+
[})](./${indexArrayItem.mdFileName})
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
${indexArrayItem.description}
|
|
50
|
+
`;
|
|
51
|
+
}
|
|
52
|
+
return indexMarkdown;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* This takes the examples folder with all the html files and generates a markdown file for each of them.
|
|
57
|
+
* It also create an index file with all the examples and their images.
|
|
58
|
+
*/
|
|
59
|
+
function generateExamplesFolder(examplesFolder) {
|
|
60
|
+
const examplesDocsFolder = path.join("docs", examplesFolder);
|
|
61
|
+
if (fs.existsSync(examplesDocsFolder)) {
|
|
62
|
+
fs.rmSync(examplesDocsFolder, { recursive: true, force: true });
|
|
63
|
+
}
|
|
64
|
+
fs.mkdirSync(examplesDocsFolder);
|
|
65
|
+
const files = fs
|
|
66
|
+
.readdirSync(examplesFolder)
|
|
67
|
+
.filter((f) => f.endsWith(".ultra"));
|
|
68
|
+
const indexArray = [];
|
|
69
|
+
for (const file of files) {
|
|
70
|
+
const queryFile = path.join(examplesFolder, file);
|
|
71
|
+
const queryContent = fs.readFileSync(queryFile, "utf-8");
|
|
72
|
+
const config = parseSettings(queryContent);
|
|
73
|
+
// fs.writeFileSync(path.join(examplesDocsFolder, file), queryContent);
|
|
74
|
+
const mdFileName = file.replace(".ultra", ".md");
|
|
75
|
+
indexArray.push({
|
|
76
|
+
title: config.title,
|
|
77
|
+
mdFileName,
|
|
78
|
+
description: config.title,
|
|
79
|
+
queryContent,
|
|
80
|
+
});
|
|
81
|
+
const exampleMarkdown = generateMarkdownForExample(
|
|
82
|
+
config,
|
|
83
|
+
file,
|
|
84
|
+
queryContent,
|
|
85
|
+
examplesFolder,
|
|
86
|
+
);
|
|
87
|
+
fs.writeFileSync(
|
|
88
|
+
path.join(examplesDocsFolder, mdFileName),
|
|
89
|
+
exampleMarkdown,
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const indexMarkdown = generateMarkdownIndexFileOfAllExamples(
|
|
94
|
+
examplesFolder,
|
|
95
|
+
indexArray,
|
|
96
|
+
);
|
|
97
|
+
fs.writeFileSync(path.join(examplesDocsFolder, "index.md"), indexMarkdown);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// !!Main flow start here!!
|
|
101
|
+
generateExamplesFolder(process.argv["2"] || "examples");
|
|
102
|
+
console.log(
|
|
103
|
+
"Docs generation completed, to see it in action run\n npm run start:docs",
|
|
104
|
+
);
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import puppeteer from "puppeteer";
|
|
4
|
+
|
|
5
|
+
const exampleName = process.argv[2];
|
|
6
|
+
const useLocalhost = process.argv.length > 3 && process.argv[3] === "serve";
|
|
7
|
+
|
|
8
|
+
const browser = await puppeteer.launch({ headless: true });
|
|
9
|
+
|
|
10
|
+
const page = await browser.newPage();
|
|
11
|
+
// set viewport and double deviceScaleFactor to get a closer shot of the map
|
|
12
|
+
await page.setViewport({
|
|
13
|
+
width: 600,
|
|
14
|
+
height: 250,
|
|
15
|
+
deviceScaleFactor: 2,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
async function createImage(exampleName) {
|
|
19
|
+
if (!fs.existsSync(`./docs/assets/${path.dirname(exampleName)}`)) {
|
|
20
|
+
fs.mkdirSync(`./docs/assets/${path.dirname(exampleName)}`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// get the example contents
|
|
24
|
+
const query = fs.readFileSync(exampleName, "utf-8");
|
|
25
|
+
if (useLocalhost) {
|
|
26
|
+
await page.goto(
|
|
27
|
+
`http://localhost:8000/#map&query=${encodeURIComponent(query)}`,
|
|
28
|
+
);
|
|
29
|
+
} else {
|
|
30
|
+
await page.goto(
|
|
31
|
+
`https://overpass-ultra.us/#map&query=${encodeURIComponent(query)}`,
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Wait for map to load, then wait two more seconds for images, etc. to load.
|
|
36
|
+
try {
|
|
37
|
+
//await page.waitForFunction('map.loaded()');
|
|
38
|
+
const waitTime = 5000;
|
|
39
|
+
console.log(`waiting for ${waitTime} ms`);
|
|
40
|
+
await new Promise((resolve) => setTimeout(resolve, waitTime));
|
|
41
|
+
} catch (err) {
|
|
42
|
+
// map.loaded() does not evaluate to true within 3 seconds, it's probably an animated example.
|
|
43
|
+
// In this case we take the screenshot immediately.
|
|
44
|
+
console.log(`Timed out waiting for map load on ${exampleName}.`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
await page
|
|
48
|
+
.screenshot({
|
|
49
|
+
path: `./docs/assets/${exampleName.replace(".ultra", ".png")}`,
|
|
50
|
+
type: "png",
|
|
51
|
+
clip: {
|
|
52
|
+
x: 0,
|
|
53
|
+
y: 0,
|
|
54
|
+
width: 600,
|
|
55
|
+
height: 250,
|
|
56
|
+
},
|
|
57
|
+
})
|
|
58
|
+
.then(() =>
|
|
59
|
+
console.log(
|
|
60
|
+
`Created ./docs/assets/${exampleName.replace(".ultra", ".png")}`,
|
|
61
|
+
),
|
|
62
|
+
)
|
|
63
|
+
.catch((err) => {
|
|
64
|
+
console.log(err);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (exampleName.endsWith("/")) {
|
|
69
|
+
const allFiles = fs
|
|
70
|
+
.readdirSync(exampleName)
|
|
71
|
+
.filter((f) => f.endsWith(".ultra"));
|
|
72
|
+
console.log(`Generating ${allFiles.length} images.`);
|
|
73
|
+
for (const file of allFiles) {
|
|
74
|
+
await createImage(path.join(exampleName, file));
|
|
75
|
+
}
|
|
76
|
+
} else if (exampleName) {
|
|
77
|
+
await createImage(exampleName);
|
|
78
|
+
} else {
|
|
79
|
+
throw new Error(`
|
|
80
|
+
Usage: npm run generate-images <file-name|all> [serve]
|
|
81
|
+
file-name: the name of the example file in test/examples without the .html extension.
|
|
82
|
+
all: generate images for all examples.
|
|
83
|
+
serve: use localhost to serve examples - use 'npm run start' with this option, otherwise it will use the latest published version in npm.
|
|
84
|
+
Example: npm run build:examples-images MapLibre-Examples/3d-buildings serve`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
await browser.close();
|
package/build-sprites.sh
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -e
|
|
3
|
+
set -x
|
|
4
|
+
|
|
5
|
+
# https://github.com/bazelbuild/rules_closure/issues/351#issuecomment-854628326
|
|
6
|
+
export OPENSSL_CONF=/dev/null
|
|
7
|
+
|
|
8
|
+
mkdir -p static/sprites
|
|
9
|
+
|
|
10
|
+
curl -L -o maki.zip https://github.com/mapbox/maki/archive/refs/heads/main.zip
|
|
11
|
+
unzip -u maki.zip
|
|
12
|
+
for icon in maki-main/icons/*.svg; do
|
|
13
|
+
npx -- svg2png $icon -o ${icon%.svg*}.png -w 30 -h 30
|
|
14
|
+
rm $icon
|
|
15
|
+
done
|
|
16
|
+
npx -- sprite-one ./static/sprites/maki -i maki-main/icons/ --sdf
|
|
17
|
+
npx -- sprite-one --ratio=2 ./static/sprites/maki@2x -i maki-main/icons/ --sdf
|
|
18
|
+
cp maki-main/LICENSE* static/sprites/maki.license
|
|
19
|
+
rm -rf maki.zip maki-main
|
|
20
|
+
#
|
|
21
|
+
curl -L -o temaki.zip https://github.com/rapideditor/temaki/archive/refs/heads/main.zip
|
|
22
|
+
unzip -u temaki.zip
|
|
23
|
+
for icon in temaki-main/icons/*.svg; do
|
|
24
|
+
npx -- svg2png $icon -o ${icon%.svg*}.png -w 30 -h 30
|
|
25
|
+
rm $icon
|
|
26
|
+
done
|
|
27
|
+
npx -- sprite-one ./static/sprites/temaki -i temaki-main/icons/ --sdf
|
|
28
|
+
npx -- sprite-one --ratio=2 ./static/sprites/temaki@2x -i temaki-main/icons/ --sdf
|
|
29
|
+
cp temaki-main/LICENSE* static/sprites/temaki.license
|
|
30
|
+
rm -rf temaki.zip temaki-main
|
package/cli/build.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import process from "process";
|
|
4
|
+
import { build } from "esbuild";
|
|
5
|
+
import { Command, Flags } from "@oclif/core";
|
|
6
|
+
|
|
7
|
+
export const ultraRoot = path.dirname(
|
|
8
|
+
path.dirname(new URL(import.meta.url).pathname),
|
|
9
|
+
);
|
|
10
|
+
export const buildOptions = (config) => ({
|
|
11
|
+
entryPoints: [path.join(ultraRoot, "index.js")],
|
|
12
|
+
bundle: true,
|
|
13
|
+
format: "esm",
|
|
14
|
+
outdir: path.join(ultraRoot, "static/dist"),
|
|
15
|
+
loader: {
|
|
16
|
+
".md": "text",
|
|
17
|
+
".css": "text",
|
|
18
|
+
".svg": "dataurl",
|
|
19
|
+
".ultra": "file",
|
|
20
|
+
".geojson": "file",
|
|
21
|
+
},
|
|
22
|
+
alias: {
|
|
23
|
+
"ultra-config": config,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export default class Build extends Command {
|
|
28
|
+
static flags = {
|
|
29
|
+
config: Flags.string({
|
|
30
|
+
char: "c",
|
|
31
|
+
description: "configuration to use",
|
|
32
|
+
default: path.join(ultraRoot, "configs/overpass-ultra.js"),
|
|
33
|
+
}),
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
static description = `Build a release of Ultra`;
|
|
37
|
+
|
|
38
|
+
async run() {
|
|
39
|
+
const {
|
|
40
|
+
flags: { config },
|
|
41
|
+
} = await this.parse(Build);
|
|
42
|
+
|
|
43
|
+
await build(buildOptions(config));
|
|
44
|
+
|
|
45
|
+
if (ultraRoot !== process.cwd()) {
|
|
46
|
+
fs.cpSync(
|
|
47
|
+
path.join(ultraRoot, "static"),
|
|
48
|
+
path.join(process.cwd(), "static"),
|
|
49
|
+
{ recursive: true },
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
package/cli/serve.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { context } from "esbuild";
|
|
3
|
+
import { Command, Flags } from "@oclif/core";
|
|
4
|
+
import Build, { buildOptions, ultraRoot } from "./build.js";
|
|
5
|
+
|
|
6
|
+
export default class Serve extends Command {
|
|
7
|
+
static flags = {
|
|
8
|
+
...Build.flags,
|
|
9
|
+
host: Flags.string({
|
|
10
|
+
char: "H",
|
|
11
|
+
description: "Host to listen on",
|
|
12
|
+
default: "localhost",
|
|
13
|
+
}),
|
|
14
|
+
port: Flags.string({
|
|
15
|
+
char: "p",
|
|
16
|
+
description: "Port number to listen on",
|
|
17
|
+
default: 8000,
|
|
18
|
+
parse: parseInt,
|
|
19
|
+
}),
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
static description = `Run an Ultra development server`;
|
|
23
|
+
|
|
24
|
+
async run() {
|
|
25
|
+
const {
|
|
26
|
+
args: { query },
|
|
27
|
+
flags: { config, host, port },
|
|
28
|
+
} = await this.parse(Serve);
|
|
29
|
+
|
|
30
|
+
const ctx = await context(buildOptions(config));
|
|
31
|
+
console.log(`Starting dev server on http://${host}:${port}`);
|
|
32
|
+
await ctx.serve({ host, port, servedir: path.join(ultraRoot, "static") });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { h, t } from "../lib/dom.js";
|
|
2
|
+
import { style as buttonCSS } from "./button.js";
|
|
3
|
+
import { normalizeCSS } from "../lib/normalize.js";
|
|
4
|
+
|
|
5
|
+
export class ButtonModal extends HTMLElement {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
}
|
|
9
|
+
get text() {
|
|
10
|
+
return this.getAttribute("text");
|
|
11
|
+
}
|
|
12
|
+
set text(value) {
|
|
13
|
+
return this.setAttribute("text", value);
|
|
14
|
+
}
|
|
15
|
+
get icon() {
|
|
16
|
+
return this.getAttribute("icon");
|
|
17
|
+
}
|
|
18
|
+
set icon(value) {
|
|
19
|
+
return this.setAttribute("icon", value);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
connectedCallback() {
|
|
23
|
+
const shadow = this.attachShadow({ mode: "open" });
|
|
24
|
+
|
|
25
|
+
const css = new CSSStyleSheet();
|
|
26
|
+
css.replaceSync(`
|
|
27
|
+
button {
|
|
28
|
+
position: relative;
|
|
29
|
+
}
|
|
30
|
+
button div span.close {
|
|
31
|
+
cursor: pointer;
|
|
32
|
+
float: right;
|
|
33
|
+
}
|
|
34
|
+
button.button-modal:after {
|
|
35
|
+
content: " ${this.text}";
|
|
36
|
+
}
|
|
37
|
+
button > div {
|
|
38
|
+
cursor: default;
|
|
39
|
+
display: none;
|
|
40
|
+
z-index: 1;
|
|
41
|
+
position: fixed;
|
|
42
|
+
top: 0;
|
|
43
|
+
bottom: 0;
|
|
44
|
+
left: 0;
|
|
45
|
+
right: 0;
|
|
46
|
+
background: rgba(0,0,0,0.5);
|
|
47
|
+
}
|
|
48
|
+
button > div.visible {
|
|
49
|
+
display: flex;
|
|
50
|
+
flex-direction: column;
|
|
51
|
+
justify-content: center;
|
|
52
|
+
align-items: center;
|
|
53
|
+
padding: 20px;
|
|
54
|
+
}
|
|
55
|
+
button > div > div {
|
|
56
|
+
max-height: 100%;
|
|
57
|
+
max-width: 100%;
|
|
58
|
+
overflow: auto;
|
|
59
|
+
cursor: default;
|
|
60
|
+
background: white;
|
|
61
|
+
border: 1px solid #8f8f9d;
|
|
62
|
+
border-radius: 4px;
|
|
63
|
+
text-align: left;
|
|
64
|
+
padding: 4px 8px;
|
|
65
|
+
}
|
|
66
|
+
@media (max-width: 900px) {
|
|
67
|
+
button.button-modal:after {
|
|
68
|
+
content: "";
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
`);
|
|
72
|
+
|
|
73
|
+
shadow.adoptedStyleSheets.push(normalizeCSS);
|
|
74
|
+
shadow.adoptedStyleSheets.push(buttonCSS);
|
|
75
|
+
shadow.adoptedStyleSheets.push(css);
|
|
76
|
+
|
|
77
|
+
const div = h(
|
|
78
|
+
"div",
|
|
79
|
+
{},
|
|
80
|
+
h("span", {}, h("fa-icon", { icon: this.icon }), t(" " + this.text)),
|
|
81
|
+
h("span", { class: "close" }, "×"),
|
|
82
|
+
h("slot", { name: "modal-content" }),
|
|
83
|
+
);
|
|
84
|
+
const backdrop = h("div", {}, div);
|
|
85
|
+
const button = h(
|
|
86
|
+
"button",
|
|
87
|
+
{ class: "button-modal" },
|
|
88
|
+
h("fa-icon", { icon: this.icon }),
|
|
89
|
+
backdrop,
|
|
90
|
+
);
|
|
91
|
+
this.refs = { button, div, backdrop };
|
|
92
|
+
|
|
93
|
+
button.addEventListener("click", () => {
|
|
94
|
+
this.toggle();
|
|
95
|
+
});
|
|
96
|
+
div.addEventListener("click", (e) => {
|
|
97
|
+
e.preventDefault();
|
|
98
|
+
e.stopPropagation();
|
|
99
|
+
});
|
|
100
|
+
div.querySelector("span.close").addEventListener("click", (e) => {
|
|
101
|
+
this.toggle();
|
|
102
|
+
e.preventDefault();
|
|
103
|
+
e.stopPropagation();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
shadow.appendChild(button);
|
|
107
|
+
}
|
|
108
|
+
toggle() {
|
|
109
|
+
this.refs.backdrop.classList.toggle("visible");
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
button,
|
|
2
|
+
.button {
|
|
3
|
+
background: white;
|
|
4
|
+
border: 1px solid #8f8f9d;
|
|
5
|
+
border-radius: 4px;
|
|
6
|
+
padding: 4px 8px;
|
|
7
|
+
cursor: pointer;
|
|
8
|
+
display: inline-block;
|
|
9
|
+
}
|
|
10
|
+
button:hover,
|
|
11
|
+
.button:hover {
|
|
12
|
+
box-shadow: inset 0 0 0 99em rgba(0, 0, 0, 0.1);
|
|
13
|
+
}
|
|
14
|
+
button:disabled:hover,
|
|
15
|
+
.button:disabled:hover {
|
|
16
|
+
box-shadow: none;
|
|
17
|
+
cursor: not-allowed;
|
|
18
|
+
}
|
|
19
|
+
button:active,
|
|
20
|
+
.button:active {
|
|
21
|
+
box-shadow: inset 0 0 0 99em rgba(0, 0, 0, 0.2);
|
|
22
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { h } from "../lib/dom.js";
|
|
2
|
+
|
|
3
|
+
const style = new CSSStyleSheet();
|
|
4
|
+
style.replace(`
|
|
5
|
+
:host {
|
|
6
|
+
display: block;
|
|
7
|
+
}
|
|
8
|
+
textarea {
|
|
9
|
+
display: block;
|
|
10
|
+
height: 100%;
|
|
11
|
+
width: 100%;
|
|
12
|
+
margin: 0;
|
|
13
|
+
padding: 5px;
|
|
14
|
+
border: 0;
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
}
|
|
17
|
+
`);
|
|
18
|
+
|
|
19
|
+
export class CodeEditor extends HTMLElement {
|
|
20
|
+
static observedAttributes = ["source"];
|
|
21
|
+
get source() {
|
|
22
|
+
return this.getAttribute("source");
|
|
23
|
+
}
|
|
24
|
+
set source(value) {
|
|
25
|
+
return this.setAttribute("source", value);
|
|
26
|
+
}
|
|
27
|
+
constructor() {
|
|
28
|
+
super();
|
|
29
|
+
}
|
|
30
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
31
|
+
if (oldValue != newValue) {
|
|
32
|
+
this.dispatchEvent(new Event("change"));
|
|
33
|
+
}
|
|
34
|
+
if (this.refs && this.refs.textarea.value !== newValue) {
|
|
35
|
+
this.refs.textarea.value = newValue;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
connectedCallback() {
|
|
39
|
+
const shadow = this.attachShadow({ mode: "open" });
|
|
40
|
+
shadow.adoptedStyleSheets.push(style);
|
|
41
|
+
const textarea = h(
|
|
42
|
+
"textarea",
|
|
43
|
+
{ autofocus: this.autofocus, spellcheck: false },
|
|
44
|
+
this.source,
|
|
45
|
+
);
|
|
46
|
+
this.refs = { textarea };
|
|
47
|
+
shadow.appendChild(textarea);
|
|
48
|
+
textarea.addEventListener("keydown", (e) => {
|
|
49
|
+
const start = e.target.selectionStart;
|
|
50
|
+
const end = e.target.selectionEnd;
|
|
51
|
+
const textFromLastNewLine =
|
|
52
|
+
start === 0
|
|
53
|
+
? ""
|
|
54
|
+
: e.target.value.slice(
|
|
55
|
+
e.target.value.slice(0, start).lastIndexOf("\n") + 1,
|
|
56
|
+
);
|
|
57
|
+
const leadingWhitespace =
|
|
58
|
+
textFromLastNewLine.match(/^([ \t])+/)?.[0] || "";
|
|
59
|
+
|
|
60
|
+
if (e.key == "Tab") {
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
e.target.value =
|
|
63
|
+
e.target.value.substring(0, start) +
|
|
64
|
+
" " +
|
|
65
|
+
e.target.value.substring(end);
|
|
66
|
+
e.target.selectionStart = e.target.selectionEnd = start + 2;
|
|
67
|
+
}
|
|
68
|
+
if (e.key == "Enter") {
|
|
69
|
+
e.preventDefault();
|
|
70
|
+
if (e.ctrlKey) {
|
|
71
|
+
this.dispatchEvent(new Event("run"));
|
|
72
|
+
} else {
|
|
73
|
+
e.target.value =
|
|
74
|
+
e.target.value.substring(0, start) +
|
|
75
|
+
"\n" +
|
|
76
|
+
leadingWhitespace +
|
|
77
|
+
e.target.value.substring(end);
|
|
78
|
+
e.target.selectionStart = e.target.selectionEnd =
|
|
79
|
+
start + 1 + leadingWhitespace.length;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
textarea.addEventListener("keyup", (e) => {
|
|
84
|
+
this.source = e.target.value;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { h } from "../lib/dom.js";
|
|
2
|
+
import { normalizeCSS } from "../lib/normalize.js";
|
|
3
|
+
import { style as buttonCSS } from "./button.js";
|
|
4
|
+
|
|
5
|
+
const style = new CSSStyleSheet();
|
|
6
|
+
style.replaceSync(`
|
|
7
|
+
button:after {
|
|
8
|
+
content: " Download";
|
|
9
|
+
}
|
|
10
|
+
@media (max-width: 900px) {
|
|
11
|
+
button:after {
|
|
12
|
+
content: "";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
`);
|
|
16
|
+
|
|
17
|
+
export class DownloadButton extends HTMLElement {
|
|
18
|
+
#data;
|
|
19
|
+
|
|
20
|
+
constructor() {
|
|
21
|
+
super();
|
|
22
|
+
}
|
|
23
|
+
set data(data) {
|
|
24
|
+
this.#data = data;
|
|
25
|
+
this.refs.button.disabled = !this.#data;
|
|
26
|
+
}
|
|
27
|
+
get data() {
|
|
28
|
+
return this.#data;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
connectedCallback() {
|
|
32
|
+
const shadow = this.attachShadow({ mode: "open" });
|
|
33
|
+
|
|
34
|
+
shadow.adoptedStyleSheets.push(normalizeCSS);
|
|
35
|
+
shadow.adoptedStyleSheets.push(buttonCSS);
|
|
36
|
+
shadow.adoptedStyleSheets.push(style);
|
|
37
|
+
|
|
38
|
+
const button = h("button", {}, h("fa-icon", { icon: "download" }));
|
|
39
|
+
button.disabled = !this.#data;
|
|
40
|
+
this.refs = { button };
|
|
41
|
+
|
|
42
|
+
button.addEventListener("click", (e) => {
|
|
43
|
+
const json = JSON.stringify(this.data);
|
|
44
|
+
const blob = new Blob([json], { type: "octet/stream" });
|
|
45
|
+
const url = window.URL.createObjectURL(blob);
|
|
46
|
+
|
|
47
|
+
const link = h("a", { download: "overpass.geojson", href: url });
|
|
48
|
+
|
|
49
|
+
// this is necessary as link.click() does not work on the latest firefox
|
|
50
|
+
link.dispatchEvent(
|
|
51
|
+
new MouseEvent("click", {
|
|
52
|
+
bubbles: true,
|
|
53
|
+
cancelable: true,
|
|
54
|
+
view: window,
|
|
55
|
+
}),
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
setTimeout(() => {
|
|
59
|
+
// For Firefox it is necessary to delay revoking the ObjectURL
|
|
60
|
+
window.URL.revokeObjectURL(url);
|
|
61
|
+
link.remove();
|
|
62
|
+
}, 100);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
shadow.appendChild(button);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
attributeChangedCallback(name, oldValue, newValue) {}
|
|
69
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { icon, library } from "@fortawesome/fontawesome-svg-core";
|
|
2
|
+
import {
|
|
3
|
+
faLink,
|
|
4
|
+
faShareNodes,
|
|
5
|
+
faQuestion,
|
|
6
|
+
faDownload,
|
|
7
|
+
faPlay,
|
|
8
|
+
faXmark,
|
|
9
|
+
faUpRightAndDownLeftFromCenter,
|
|
10
|
+
faDownLeftAndUpRightToCenter,
|
|
11
|
+
faPaintbrush,
|
|
12
|
+
faPenToSquare,
|
|
13
|
+
} from "@fortawesome/free-solid-svg-icons";
|
|
14
|
+
|
|
15
|
+
import { h } from "../lib/dom.js";
|
|
16
|
+
import buttonStyle from "./button.css";
|
|
17
|
+
import { style as buttonCSS } from "./button.js";
|
|
18
|
+
import { normalizeCSS } from "../lib/normalize.js";
|
|
19
|
+
|
|
20
|
+
library.add(faLink);
|
|
21
|
+
library.add(faShareNodes);
|
|
22
|
+
library.add(faQuestion);
|
|
23
|
+
library.add(faDownload);
|
|
24
|
+
library.add(faPlay);
|
|
25
|
+
library.add(faXmark);
|
|
26
|
+
library.add(faUpRightAndDownLeftFromCenter);
|
|
27
|
+
library.add(faDownLeftAndUpRightToCenter);
|
|
28
|
+
library.add(faPaintbrush);
|
|
29
|
+
library.add(faPenToSquare);
|
|
30
|
+
|
|
31
|
+
export const css = new CSSStyleSheet();
|
|
32
|
+
css.replaceSync(`
|
|
33
|
+
:host {
|
|
34
|
+
display: inline-block;
|
|
35
|
+
vertical-align: top;
|
|
36
|
+
}
|
|
37
|
+
svg {
|
|
38
|
+
display: inline-block;
|
|
39
|
+
height: 1em;
|
|
40
|
+
width: 1em;
|
|
41
|
+
vertical-align: top;
|
|
42
|
+
padding: 1px 0;
|
|
43
|
+
}
|
|
44
|
+
`);
|
|
45
|
+
|
|
46
|
+
export class FontAwesomeIcon extends HTMLElement {
|
|
47
|
+
static observedAttributes = ["icon"];
|
|
48
|
+
|
|
49
|
+
get icon() {
|
|
50
|
+
return this.getAttribute("icon");
|
|
51
|
+
}
|
|
52
|
+
set icon(value) {
|
|
53
|
+
this.setAttribute("icon", value);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
constructor() {
|
|
57
|
+
super();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
connectedCallback() {
|
|
61
|
+
this.shadow = this.attachShadow({ mode: "open" });
|
|
62
|
+
|
|
63
|
+
this.shadow.adoptedStyleSheets.push(normalizeCSS);
|
|
64
|
+
this.shadow.adoptedStyleSheets.push(css);
|
|
65
|
+
|
|
66
|
+
const { html } = icon({ prefix: "fas", iconName: this.icon });
|
|
67
|
+
|
|
68
|
+
this.shadow.innerHTML = html[0];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
72
|
+
if (!this.shadow) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const { html } = icon({ prefix: "fas", iconName: this.icon });
|
|
77
|
+
|
|
78
|
+
this.shadow.innerHTML = html[0];
|
|
79
|
+
}
|
|
80
|
+
}
|