From 23b3890e1cfef7573f6a54d9569192262307bcaa Mon Sep 17 00:00:00 2001 From: Russ Garrett Date: Sun, 19 May 2024 10:35:25 +0100 Subject: [PATCH] Embed URL param --- web/src/index.ts | 59 +++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/web/src/index.ts b/web/src/index.ts index 62686a6..0692fea 100644 --- a/web/src/index.ts +++ b/web/src/index.ts @@ -86,32 +86,39 @@ class EventMap { this.map.touchZoomRotate.disableRotation() - this.map.addControl(new maplibregl.NavigationControl(), 'top-right') - - this.map.addControl( - new maplibregl.GeolocateControl({ - positionOptions: { - enableHighAccuracy: true, - }, - trackUserLocation: true, - }) - ) - - this.map.addControl( - new maplibregl.ScaleControl({ - maxWidth: 200, - unit: 'metric', - }) - ) - - this.map.addControl(new DistanceMeasure(), 'top-right') - this.map.addControl(new InstallControl(), 'top-left') - - this.map.addControl(new VillagesEditor('villages', 'villages_symbol'), 'top-right') - - // Display edit control only on browsers which are likely to be desktop browsers - if (window.matchMedia('(min-width: 600px)').matches) { - this.map.addControl(new ExportControl(loadIcons), 'top-right') + const url = new URL(window.location.href) + const embed = url.searchParams.get('embed') == 'true' + + if (!embed) { + this.map.addControl(new maplibregl.NavigationControl(), 'top-right') + + this.map.addControl( + new maplibregl.GeolocateControl({ + positionOptions: { + enableHighAccuracy: true, + }, + trackUserLocation: true, + }) + ) + + this.map.addControl( + new maplibregl.ScaleControl({ + maxWidth: 200, + unit: 'metric', + }) + ) + + this.map.addControl(new DistanceMeasure(), 'top-right') + this.map.addControl(new InstallControl(), 'top-left') + + this.map.addControl(new VillagesEditor('villages', 'villages_symbol'), 'top-right') + + // Display edit control only on browsers which are likely to be desktop browsers + if (window.matchMedia('(min-width: 600px)').matches) { + this.map.addControl(new ExportControl(loadIcons), 'top-right') + } + } else { + document.querySelector('header')!.style.display = 'none' } this.map.addControl(this.layer_switcher, 'top-right')