Skip to content

Commit 5cf6994

Browse files
committed
fix: added support for stadia tiles API
1 parent 3839710 commit 5cf6994

7 files changed

Lines changed: 35 additions & 7 deletions

File tree

.env.example

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
VITE_SUPABASE_URL=
22
VITE_SUPABASE_ANON_KEY=
3+
VITE_STADIA_API_KEY=
34
# Example Supabase configuration
4-
# Uncomment and set your Supabase URL and Anon Key below
5+
# Uncomment and set your Supabase URL, Anon Key, and Stadia API key below
56
# VITE_SUPABASE_URL=https://your-supabase-url.supabase.co
67
# VITE_SUPABASE_ANON_KEY=your-anon-key
8+
# VITE_STADIA_API_KEY=your-stadia-api-key
79

.github/workflows/deploy-pages.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
env:
4040
VITE_SUPABASE_URL: ${{ secrets.VITE_SUPABASE_URL }}
4141
VITE_SUPABASE_ANON_KEY: ${{ secrets.VITE_SUPABASE_ANON_KEY }}
42+
VITE_STADIA_API_KEY: ${{ secrets.VITE_STADIA_API_KEY }}
4243

4344
- name: SPA fallback for direct route loads
4445
run: cp dist/index.html dist/404.html

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ Local mode runs Supabase services in Docker containers on your machine.
144144

145145
This repo includes a GitHub Pages workflow at `.github/workflows/deploy-pages.yml`.
146146

147+
Set these in **Settings** -> **Secrets and variables** -> **Actions**:
148+
149+
- `VITE_SUPABASE_URL`
150+
- `VITE_SUPABASE_ANON_KEY`
151+
- `VITE_STADIA_API_KEY`
152+
147153
## Database Management
148154

149155
### Test User Credentials

src/config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY;
22
const supabaseUrl = import.meta.env.VITE_SUPABASE_URL;
3+
const stadiaApiKey = import.meta.env.VITE_STADIA_API_KEY;
34

4-
if (!supabaseAnonKey || !supabaseUrl) {
5+
if (!supabaseAnonKey || !supabaseUrl || !stadiaApiKey) {
56
throw new Error("Missing required application configuration.");
67
}
78

89
export const SUPABASE_ANON_KEY = supabaseAnonKey;
910
export const SUPABASE_URL = supabaseUrl;
11+
export const STADIA_API_KEY = stadiaApiKey;

src/pages/MapPage/MemorialSitesMapPage.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
MemorialFeatureType,
1010
} from "../../supabase/memorialSites";
1111
import supabase from "../../supabase";
12+
import { STADIA_API_KEY } from "../../config";
1213
import MemorialSiteForm from "./MemorialSiteForm";
1314
import localMemorialIconUrl from "../../assets/memorial-sites/local-memorial-site.png";
1415
import regionalMemorialIconUrl from "../../assets/memorial-sites/regional-memorial-site.png";
@@ -60,8 +61,10 @@ const MemorialSitesMapPage = () => {
6061
mapContainer.innerHTML = "";
6162

6263
mapRef.current = L.map("map", { zoomControl: false }).setView([31.42, 34.49], 13);
63-
L.tileLayer("https://tiles.stadiamaps.com/tiles/alidade_satellite/{z}/{x}/{y}{r}.jpg", {
64+
L.tileLayer(`https://tiles.stadiamaps.com/tiles/alidade_satellite/{z}/{x}/{y}{r}.jpg?api_key=${STADIA_API_KEY}`, {
6465
maxZoom: 19,
66+
attribution:
67+
'&copy; <a href="https://stadiamaps.com/" target="_blank" rel="noopener noreferrer">Stadia Maps</a> &copy; <a href="https://openmaptiles.org/" target="_blank" rel="noopener noreferrer">OpenMapTiles</a> &copy; <a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noopener noreferrer">OpenStreetMap</a> contributors',
6568
}).addTo(mapRef.current);
6669

6770
L.control.zoom({ position: "bottomright" }).addTo(mapRef.current);

src/pages/MapPage/PinkLineMapPage.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ import { createPinkLineNode, loadPinkLineNodes, submitPinkLineRoute, deletePinkL
77
import { optimizeRoute } from "../../utils/routeOptimizer";
88
import { parseDefaultLinePaths, buildIntegratedRoute } from "../../utils/pinkLineRoute";
99
import supabase from "../../supabase";
10+
import { STADIA_API_KEY } from "../../config";
1011
import PinkLineNodeForm from "./PinkLineNodeForm";
1112

12-
const DEFAULT_PINK_LINE_URL = `${import.meta.env.BASE_URL}line-layer/pink-line-wgs84.geojson`;
13+
const APP_BASE_URL = import.meta.env.BASE_URL.endsWith("/")
14+
? import.meta.env.BASE_URL
15+
: `${import.meta.env.BASE_URL}/`;
16+
const DEFAULT_PINK_LINE_URL = `${APP_BASE_URL}line-layer/pink-line-wgs84.geojson`;
1317

1418
interface PinkLineNode {
1519
id: string;
@@ -74,9 +78,11 @@ const PinkLineMapPage = () => {
7478
mapRef.current = L.map("map").setView([31.42, 34.49], 13);
7579

7680
L.tileLayer(
77-
"https://tiles.stadiamaps.com/tiles/alidade_satellite/{z}/{x}/{y}{r}.jpg",
81+
`https://tiles.stadiamaps.com/tiles/alidade_satellite/{z}/{x}/{y}{r}.jpg?api_key=${STADIA_API_KEY}`,
7882
{
7983
maxZoom: 19,
84+
attribution:
85+
'&copy; <a href="https://stadiamaps.com/" target="_blank" rel="noopener noreferrer">Stadia Maps</a> &copy; <a href="https://openmaptiles.org/" target="_blank" rel="noopener noreferrer">OpenMapTiles</a> &copy; <a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noopener noreferrer">OpenStreetMap</a> contributors',
8086
}
8187
).addTo(mapRef.current);
8288

@@ -120,7 +126,12 @@ const PinkLineMapPage = () => {
120126
new customControls({ position: "topleft" }).addTo(mapRef.current);
121127

122128
fetch(DEFAULT_PINK_LINE_URL)
123-
.then((res) => res.json())
129+
.then((res) => {
130+
if (!res.ok) {
131+
throw new Error(`Failed to fetch pink line GeoJSON (${res.status})`);
132+
}
133+
return res.json();
134+
})
124135
.then((geojson: GeoJSON.FeatureCollection) => {
125136
if (!mapRef.current) return;
126137
defaultLinePathsRef.current = parseDefaultLinePaths(geojson);

src/pages/MapPage/hooks/useMap.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import "leaflet/dist/leaflet.css";
44
import "leaflet-draw/dist/leaflet.draw.css";
55
import "leaflet-draw";
66
import "../../../types/leaflet.d.ts";
7+
import { STADIA_API_KEY } from "../../../config";
78
import {
89
createGeometry,
910
deleteGeometry,
@@ -55,9 +56,11 @@ export const useMap = ({ center, enabled = true, onShapeCreated, isHebrew }: Use
5556
mapRef.current = L.map("map").setView(center, 16);
5657

5758
L.tileLayer(
58-
"https://tiles.stadiamaps.com/tiles/alidade_satellite/{z}/{x}/{y}{r}.jpg",
59+
`https://tiles.stadiamaps.com/tiles/alidade_satellite/{z}/{x}/{y}{r}.jpg?api_key=${STADIA_API_KEY}`,
5960
{
6061
maxZoom: 19,
62+
attribution:
63+
'&copy; <a href="https://stadiamaps.com/" target="_blank" rel="noopener noreferrer">Stadia Maps</a> &copy; <a href="https://openmaptiles.org/" target="_blank" rel="noopener noreferrer">OpenMapTiles</a> &copy; <a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noopener noreferrer">OpenStreetMap</a> contributors',
6164
}
6265
).addTo(mapRef.current);
6366

0 commit comments

Comments
 (0)