@@ -7,9 +7,13 @@ import { createPinkLineNode, loadPinkLineNodes, submitPinkLineRoute, deletePinkL
77import { optimizeRoute } from "../../utils/routeOptimizer" ;
88import { parseDefaultLinePaths , buildIntegratedRoute } from "../../utils/pinkLineRoute" ;
99import supabase from "../../supabase" ;
10+ import { STADIA_API_KEY } from "../../config" ;
1011import 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
1418interface 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+ '© <a href="https://stadiamaps.com/" target="_blank" rel="noopener noreferrer">Stadia Maps</a> © <a href="https://openmaptiles.org/" target="_blank" rel="noopener noreferrer">OpenMapTiles</a> © <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 ) ;
0 commit comments