From 72ba39cef34b170a75c08e163bd86608d6058aa4 Mon Sep 17 00:00:00 2001 From: Hidde Wieringa Date: Sat, 13 Jun 2026 20:11:32 +0200 Subject: [PATCH 1/3] extract geolocateControl and add event handler --- proxy/js/ui.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/proxy/js/ui.js b/proxy/js/ui.js index bc7779195..8fd6b1dff 100644 --- a/proxy/js/ui.js +++ b/proxy/js/ui.js @@ -2240,19 +2240,24 @@ const navigationControl = new maplibregl.NavigationControl({ showCompass: true, visualizePitch: true, }) +const geolocateControl = new maplibregl.GeolocateControl({ + positionOptions: { + enableHighAccuracy: true + }, + trackUserLocation: true, + showAccuracyCircle: false, + showUserLocation: true, +}) +geolocateControl.on('trackuserlocationstart', () => { + console.info('acquire wake lock') +}) +geolocateControl.on('trackuserlocationend', () => { + console.info('release wake lock') +}) map.addControl(dateControl); map.addControl(styleControl); map.addControl(navigationControl); -map.addControl( - new maplibregl.GeolocateControl({ - positionOptions: { - enableHighAccuracy: true - }, - trackUserLocation: true, - showAccuracyCircle: false, - showUserLocation: true, - }) -); +map.addControl(geolocateControl); map.addControl(new EditControl()); map.addControl(new ConfigurationControl()); From 0eeb9413f88fe74c46f8c3d059033106a56dadcc Mon Sep 17 00:00:00 2001 From: Hidde Wieringa Date: Sat, 13 Jun 2026 20:22:15 +0200 Subject: [PATCH 2/3] implement wakelock, if supported --- proxy/js/ui.js | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/proxy/js/ui.js b/proxy/js/ui.js index 8fd6b1dff..9471dbcca 100644 --- a/proxy/js/ui.js +++ b/proxy/js/ui.js @@ -2248,12 +2248,37 @@ const geolocateControl = new maplibregl.GeolocateControl({ showAccuracyCircle: false, showUserLocation: true, }) -geolocateControl.on('trackuserlocationstart', () => { - console.info('acquire wake lock') -}) -geolocateControl.on('trackuserlocationend', () => { - console.info('release wake lock') -}) + +class WakeLock { + constructor() { + this.wakeLock = null; + } + + acquire() { + if (navigator.wakeLock) { + navigator.wakeLock.request('screen') + .then(lock => { + if (this.wakeLock) { + this.wakeLock.release(); + } + this.wakeLock = lock; + console.info('Acquired wake lock') + }) + .catch(error => console.warn('Acquiring of wakelock failed', error)); + } + } + + release() { + if (this.wakeLock) { + this.wakeLock.release() + console.info('Released wake lock') + } + } +} + +let wakeLock = new WakeLock() +geolocateControl.on('trackuserlocationstart', () => wakeLock.acquire()) +geolocateControl.on('trackuserlocationend', () => wakeLock.release()) map.addControl(dateControl); map.addControl(styleControl); map.addControl(navigationControl); From 0f6d34467b7366dab8700886b33feb3aeb7516b7 Mon Sep 17 00:00:00 2001 From: Hidde Wieringa Date: Sat, 13 Jun 2026 20:24:19 +0200 Subject: [PATCH 3/3] message --- proxy/js/ui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proxy/js/ui.js b/proxy/js/ui.js index 9471dbcca..a214a5393 100644 --- a/proxy/js/ui.js +++ b/proxy/js/ui.js @@ -2264,7 +2264,7 @@ class WakeLock { this.wakeLock = lock; console.info('Acquired wake lock') }) - .catch(error => console.warn('Acquiring of wakelock failed', error)); + .catch(error => console.warn('Acquiring of wake lock failed', error)); } }