Skip to content

Commit 707e209

Browse files
committed
Use different tiles
1 parent 2a3a92a commit 707e209

File tree

2 files changed

+14
-43
lines changed

2 files changed

+14
-43
lines changed

app/public/serviceworker.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,12 @@ addEventListener("fetch", (fetchEvent) => {
7272

7373
fetchEvent.respondWith(
7474
(async function () {
75-
const targetCacheName = request.url.includes("cartocdn.com")
76-
? tileCacheName
77-
: generalCacheName;
75+
const targetCacheName =
76+
// TODO: remove
77+
request.url.includes("cartocdn.com") ||
78+
request.url.includes("tile.openstreetmap.org")
79+
? tileCacheName
80+
: generalCacheName;
7881

7982
const responseFromFetch = fetch(request);
8083
if (request.headers.get("Accept").includes("text/html")) {

app/source/library/game/Map.svelte

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import roundNumber from "../../utilities/roundNumber";
2424
import waitForAnyOngoingZoomsToEnd from "../../utilities/waitForAnyOngoingZoomsToEnd";
2525
import { writable } from "svelte/store";
26-
import type { HTMLSharpImage } from "../customElements";
2726
import createLeafletFeatureGroupFromAreaSelection from "../utilities/createLeafletFeatureGroupFromAreaSelection";
2827
import updateAreaCenterWithWarningIfNecessary from "../utilities/updateAreaCenterWithWarningIfNecessary";
2928
import {
@@ -43,8 +42,8 @@
4342
} from "../../utilities/store";
4443
import { isOrganizationUrl } from "../../userData/store";
4544
46-
const shouldUseSimpleTileLayers = true;
47-
const shouldAlwaysShowBaseTileLayer = !shouldUseSimpleTileLayers;
45+
const shouldAlwaysShowBaseTileLayer = true;
46+
const shouldOnlyShowBaseTileLayer = true;
4847
const getBoundsPaddingWhenMarkingBounds = () =>
4948
getViewportWidth() >= 800 ? 0.2 : 0;
5049
export let areSettingsShown = writable(false);
@@ -62,30 +61,15 @@
6261
const maxMapZoom = 23; // https://github.com/adam-lynch/back-of-your-hand/issues/38#issuecomment-1079887466
6362
let resultFeatureGroup: leaflet.FeatureGroup | null;
6463
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-
7964
const getTileLayer = (name: "base" | "labels") => {
8065
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",
8468
};
8569
86-
return new CustomTileLayer(nameToUrlMap[name], {
70+
return new leaflet.TileLayer(nameToUrlMap[name], {
8771
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+
'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
8973
maxNativeZoom: 18,
9074
maxZoom: maxMapZoom,
9175
});
@@ -189,7 +173,7 @@
189173
};
190174
191175
const hideElementLabels = async (): Promise<void> => {
192-
if (!areElementLabelsShown) {
176+
if (shouldOnlyShowBaseTileLayer || !areElementLabelsShown) {
193177
return;
194178
}
195179
@@ -204,7 +188,7 @@
204188
};
205189
206190
const showElementLabels = async (): Promise<void> => {
207-
if (areElementLabelsShown) {
191+
if (shouldOnlyShowBaseTileLayer || areElementLabelsShown) {
208192
return;
209193
}
210194
@@ -800,22 +784,6 @@
800784
opacity: 0.8 !important;
801785
}
802786
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-
819787
& sharp-img {
820788
position: relative;
821789
overflow: hidden;

0 commit comments

Comments
 (0)