aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/app/maps
diff options
context:
space:
mode:
authorAriel Costas Guerrero <ariel@costas.dev>2025-11-19 23:54:49 +0100
committerAriel Costas Guerrero <ariel@costas.dev>2025-11-19 23:54:49 +0100
commitf030f1806255c66b86689489d24f8f5ad9b832ce (patch)
treea776e6a6670b50bb43609633cdbd1fe9857b8065 /src/frontend/app/maps
parent3ebb062e99dbd8a63d5642d67ba4be753e61a34d (diff)
feat: Implement StopMapModal component for displaying bus stop locations with live tracking; enhance styles and add interaction features
Diffstat (limited to 'src/frontend/app/maps')
-rw-r--r--src/frontend/app/maps/styleloader.ts26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/frontend/app/maps/styleloader.ts b/src/frontend/app/maps/styleloader.ts
index 43118a0..8109e0b 100644
--- a/src/frontend/app/maps/styleloader.ts
+++ b/src/frontend/app/maps/styleloader.ts
@@ -1,10 +1,17 @@
import type { StyleSpecification } from "react-map-gl/maplibre";
import type { Theme } from "~/AppContext";
+export interface StyleLoaderOptions {
+ includeTraffic?: boolean;
+}
+
export async function loadStyle(
styleName: string,
- colorScheme: Theme
+ colorScheme: Theme,
+ options?: StyleLoaderOptions
): Promise<StyleSpecification> {
+ const { includeTraffic = true } = options || {};
+
if (colorScheme == "system") {
const isDarkMode = window.matchMedia(
"(prefers-color-scheme: dark)"
@@ -21,6 +28,15 @@ export async function loadStyle(
}
const style = await resp.json();
+
+ // Remove traffic layers if not requested
+ if (!includeTraffic) {
+ style.layers = (style.layers || []).filter(
+ (layer: any) => !layer.id?.startsWith("vigo_traffic")
+ );
+ delete style.sources?.vigo_traffic;
+ }
+
return style as StyleSpecification;
}
@@ -33,6 +49,14 @@ export async function loadStyle(
const style = await resp.json();
+ // Remove traffic layers if not requested
+ if (!includeTraffic) {
+ style.layers = (style.layers || []).filter(
+ (layer: any) => !layer.id?.startsWith("vigo_traffic")
+ );
+ delete style.sources?.vigo_traffic;
+ }
+
const baseUrl = window.location.origin;
const spritePath = style.sprite;