|
23 | 23 | import roundNumber from "../../utilities/roundNumber"; |
24 | 24 | import waitForAnyOngoingZoomsToEnd from "../../utilities/waitForAnyOngoingZoomsToEnd"; |
25 | 25 | import { writable } from "svelte/store"; |
26 | | - import type { HTMLSharpImage } from "../customElements"; |
27 | 26 | import createLeafletFeatureGroupFromAreaSelection from "../utilities/createLeafletFeatureGroupFromAreaSelection"; |
28 | 27 | import updateAreaCenterWithWarningIfNecessary from "../utilities/updateAreaCenterWithWarningIfNecessary"; |
29 | 28 | import { |
|
43 | 42 | } from "../../utilities/store"; |
44 | 43 | import { isOrganizationUrl } from "../../userData/store"; |
45 | 44 |
|
46 | | - const shouldUseSimpleTileLayers = true; |
47 | | - const shouldAlwaysShowBaseTileLayer = !shouldUseSimpleTileLayers; |
| 45 | + const shouldAlwaysShowBaseTileLayer = true; |
| 46 | + const shouldOnlyShowBaseTileLayer = true; |
48 | 47 | const getBoundsPaddingWhenMarkingBounds = () => |
49 | 48 | getViewportWidth() >= 800 ? 0.2 : 0; |
50 | 49 | export let areSettingsShown = writable(false); |
|
62 | 61 | const maxMapZoom = 23; // https://github.com/adam-lynch/back-of-your-hand/issues/38#issuecomment-1079887466 |
63 | 62 | let resultFeatureGroup: leaflet.FeatureGroup | null; |
64 | 63 |
|
65 | | - const CustomTileLayer = leaflet.TileLayer.extend({ |
66 | | - createTile: function (coords: unknown, done: () => void) { |
67 | | - const tile = document.createElement("sharp-img") as HTMLSharpImage; |
68 | | - tile.onload = leaflet.bind(this._tileOnLoad, this, done, tile); |
69 | | - tile.onerror = leaflet.bind(this._tileOnError, this, done, tile); |
70 | | -
|
71 | | - tile.alt = ""; |
72 | | - tile.src = this.getTileUrl(coords); |
73 | | - tile.setAttribute("role", "presentation"); |
74 | | -
|
75 | | - return tile; |
76 | | - }, |
77 | | - }) as unknown as typeof leaflet.TileLayer; |
78 | | -
|
79 | 64 | const getTileLayer = (name: "base" | "labels") => { |
80 | 65 | const nameToUrlMap = { |
81 | | - base: "https://{s}.basemaps.cartocdn.com/rastertiles/voyager_nolabels/{z}/{x}/{y}{r}.png", |
82 | | - labels: |
83 | | - "https://{s}.basemaps.cartocdn.com/rastertiles/voyager_labels_under/{z}/{x}/{y}{r}.png", |
| 66 | + base: "https://tile.openstreetmap.org/{z}/{x}/{y}.png", |
| 67 | + labels: "https://tile.openstreetmap.org/{z}/{x}/{y}.png", |
84 | 68 | }; |
85 | 69 |
|
86 | | - return new CustomTileLayer(nameToUrlMap[name], { |
| 70 | + return new leaflet.TileLayer(nameToUrlMap[name], { |
87 | 71 | attribution: |
88 | | - '\u003ca href="https://carto.com/legal/" target="_blank"\u003e\u0026copy; Carto\u003c/a\u003e \u003ca href="https://www.openstreetmap.org/copyright" target="_blank"\u003e\u0026copy; OpenStreetMap contributors\u003c/a\u003e', |
| 72 | + '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors', |
89 | 73 | maxNativeZoom: 18, |
90 | 74 | maxZoom: maxMapZoom, |
91 | 75 | }); |
|
189 | 173 | }; |
190 | 174 |
|
191 | 175 | const hideElementLabels = async (): Promise<void> => { |
192 | | - if (!areElementLabelsShown) { |
| 176 | + if (shouldOnlyShowBaseTileLayer || !areElementLabelsShown) { |
193 | 177 | return; |
194 | 178 | } |
195 | 179 |
|
|
204 | 188 | }; |
205 | 189 |
|
206 | 190 | const showElementLabels = async (): Promise<void> => { |
207 | | - if (areElementLabelsShown) { |
| 191 | + if (shouldOnlyShowBaseTileLayer || areElementLabelsShown) { |
208 | 192 | return; |
209 | 193 | } |
210 | 194 |
|
|
800 | 784 | opacity: 0.8 !important; |
801 | 785 | } |
802 | 786 |
|
803 | | - & #map:not(.leaflet-safari) .leaflet-tile-container { |
804 | | - filter: grayscale(0.8); |
805 | | - } |
806 | | -
|
807 | | - & #map:not(.leaflet-safari) .leaflet-tile { |
808 | | - filter: saturate(8) hue-rotate(-10deg); |
809 | | - } |
810 | | -
|
811 | | - /* Safari filters are broken */ |
812 | | - & .leaflet-safari .leaflet-tile-pane .leaflet-layer { |
813 | | - filter: grayscale(0.9); |
814 | | - } |
815 | | - & .leaflet-safari .leaflet-tile-container { |
816 | | - filter: saturate(4) hue-rotate(-10deg); |
817 | | - } |
818 | | -
|
819 | 787 | & sharp-img { |
820 | 788 | position: relative; |
821 | 789 | overflow: hidden; |
|
0 commit comments