From 0b7d76c7f7591c4bd68883d022bfdd83b2d0067e Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Wed, 19 Feb 2025 00:40:12 -0800 Subject: [PATCH] dont query the entire damn globe at once --- src/components/addLayers/addLiveDots.ts | 16 +++++++++------- .../fetch_realtime_vehicle_locations.ts | 17 +++++++++++++++-- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/components/addLayers/addLiveDots.ts b/src/components/addLayers/addLiveDots.ts index f2526f15..ff596828 100644 --- a/src/components/addLayers/addLiveDots.ts +++ b/src/components/addLayers/addLiveDots.ts @@ -56,13 +56,15 @@ export async function makeCircleLayers(map: Map, darkMode: boolean, layerspercat ['literal', [0, -60]] ]; - const pointing_shell_light_image = await map.loadImage('/icons/pointing-shell-light.png'); - map.addImage('pointingshelllight', pointing_shell_light_image.data); + const [pointing_shell_light_image, pointing_filled_image, pointing_shell_image] = + await Promise.all([ + map.loadImage('/icons/pointing-shell-light.png'), + map.loadImage('/icons/pointing-filled.png'), + map.loadImage('/icons/pointing-shell.png') + ]); - const pointing_filled_image = await map.loadImage('/icons/pointing-filled.png'); + map.addImage('pointingshelllight', pointing_shell_light_image.data); map.addImage('pointingcoloured', pointing_filled_image.data, { sdf: true }); - - const pointing_shell_image = await map.loadImage('/icons/pointing-shell.png'); map.addImage('pointingshell', pointing_shell_image.data); console.log('shells loaded'); @@ -80,7 +82,7 @@ export async function makeCircleLayers(map: Map, darkMode: boolean, layerspercat //'circle-emissive-strength': 1, 'circle-opacity': 0.5 }, - minzoom: 8.5 + minzoom: 6 }); map.addLayer({ @@ -294,7 +296,7 @@ export async function makeCircleLayers(map: Map, darkMode: boolean, layerspercat 'icon-color': ['get', 'contrastdarkmodebearing'], 'icon-opacity': 1 }, - minZoom: 2, + minZoom: 4.5, layout: { 'icon-image': 'pointingcoloured', 'icon-allow-overlap': true, diff --git a/src/components/fetch_realtime_vehicle_locations.ts b/src/components/fetch_realtime_vehicle_locations.ts index 1a72b6d7..0bfc1477 100644 --- a/src/components/fetch_realtime_vehicle_locations.ts +++ b/src/components/fetch_realtime_vehicle_locations.ts @@ -24,20 +24,33 @@ export function fetch_realtime_vehicle_locations( const categories_to_request: string[] = []; if (layersettings.bus.visible) { + if (map.getZoom() > 6) { + categories_to_request.push('bus'); + } + + } + if (map.getZoom() > 3) { if (layersettings.intercityrail.visible) { categories_to_request.push('rail'); } + } - if (layersettings.localrail.visible) { - categories_to_request.push('metro'); + if (map.getZoom() > 4) { + if (layersettings.localrail.visible) { + categories_to_request.push('metro'); + } } + if (map.getZoom() > 3) { + + if (layersettings.other.visible) { categories_to_request.push('other'); } + } const realtime_chateaus_in_frame = get(chateaus_in_frame).filter((chateau_id: string) => { return chateau_to_realtime_feed_lookup[chateau_id].length > 0;