From 2d0200600d9ab5a021b80e0799bb2c29404ee62b Mon Sep 17 00:00:00 2001 From: Dennis Sen Date: Fri, 14 Feb 2025 12:12:47 +0100 Subject: [PATCH 1/3] extend diplan example --- packages/clients/diplan/example/config.js | 1 + packages/clients/diplan/example/index.html | 20 +++++- .../clients/diplan/example/prod-example.html | 6 +- packages/clients/diplan/example/setup.js | 61 +++++++++++++++++++ packages/clients/diplan/example/style.css | 8 +++ packages/clients/diplan/src/polar-client.ts | 1 + 6 files changed, 91 insertions(+), 6 deletions(-) diff --git a/packages/clients/diplan/example/config.js b/packages/clients/diplan/example/config.js index 4a0f29368..cf341b26d 100644 --- a/packages/clients/diplan/example/config.js +++ b/packages/clients/diplan/example/config.js @@ -30,6 +30,7 @@ export default { // TODO should we provide english locales? ], addressSearch: { + displayComponent: true, searchMethods: [ { queryParameters: { diff --git a/packages/clients/diplan/example/index.html b/packages/clients/diplan/example/index.html index da825af18..8c6202313 100644 --- a/packages/clients/diplan/example/index.html +++ b/packages/clients/diplan/example/index.html @@ -15,6 +15,20 @@

Testseite @polar/client-diplan (dev)

Beispielinstanz

+
+

Steuerung von außen

+ + + + + + +
+
+

Klient

@@ -47,9 +61,9 @@

Informationen aus Kartenklient

Wert der aktuellen GetFeatureInformation-Antwort(en) als Record<LayerId, Feature[]> - plugin/... - uninitialized - Text + plugin/draw/featureCollection + uninitialized + Die hergestellte Zeichnung als GeoJSON. plugin/... diff --git a/packages/clients/diplan/example/prod-example.html b/packages/clients/diplan/example/prod-example.html index 8f01efd3f..02c9df30a 100644 --- a/packages/clients/diplan/example/prod-example.html +++ b/packages/clients/diplan/example/prod-example.html @@ -47,9 +47,9 @@

Informationen aus Kartenklient

Wert der aktuellen GetFeatureInformation-Antwort(en) als Record<LayerId, Feature[]> - plugin/... - uninitialized - Text + plugin/draw/featureCollection + uninitialized + Die hergestellte Zeichnung als GeoJSON. plugin/... diff --git a/packages/clients/diplan/example/setup.js b/packages/clients/diplan/example/setup.js index edbb65104..757f19095 100644 --- a/packages/clients/diplan/example/setup.js +++ b/packages/clients/diplan/example/setup.js @@ -1,5 +1,27 @@ /* eslint-disable max-lines-per-function */ +const geoJSON = { + type: 'FeatureCollection', + features: [ + { + type: 'Feature', + properties: {}, + geometry: { + type: 'Polygon', + coordinates: [ + [ + [553702.4519707427, 5926504.665153537], + [549799.849911481, 5938873.929307467], + [582674.3113259386, 5942313.510783426], + [572421.7126956752, 5930142.68402234], + [553702.4519707427, 5926504.665153537], + ], + ], + }, + }, + ], +} + /* this is an example setup function displaying how POLAR is instantiated * you may do this in any other format as long as all required contents arrive * in `initializeLayerList` and `createMap` */ @@ -40,10 +62,46 @@ export default (client, layerConf, config) => { // TODO expand example bindings + const actionPlus = document.getElementById('action-plus') + const actionMinus = document.getElementById('action-minus') + const actionToast = document.getElementById('action-toast') + const actionLoadGeoJson = document.getElementById('action-load-geojson') + const actionZoomToAll = document.getElementById('action-zoom-to-all') + const actionFillAddressSearch = document.getElementById( + 'action-address-search-filler' + ) + + actionPlus.onclick = () => + mapInstance.$store.dispatch('plugin/zoom/increaseZoomLevel') + actionMinus.onclick = () => + mapInstance.$store.dispatch('plugin/zoom/decreaseZoomLevel') + actionToast.onclick = () => + mapInstance.$store.dispatch('plugin/toast/addToast', { + type: 'success', + text: 'Dies ist eine Beispielnachricht.', + timeout: 3000, + }) + actionLoadGeoJson.onclick = () => { + mapInstance.$store.dispatch('plugin/draw/addFeatures', { + geoJSON, + }) + } + actionZoomToAll.onclick = () => + mapInstance.$store.dispatch('plugin/draw/zoomToAllFeatures', { + margin: 10, // defaults to 20 + }) + actionFillAddressSearch.addEventListener('input', (e) => + mapInstance.$store.dispatch('plugin/addressSearch/search', { + input: e.target.value, + autoselect: 'first', + }) + ) + const htmlZoom = document.getElementById('subscribed-zoom') const htmlGfi = document.getElementById('subscribed-gfi') const htmlExportA = document.getElementById('subscribed-export-a') const htmlExportImg = document.getElementById('subscribed-export-img') + const htmlDraw = document.getElementById('subscribed-draw') mapInstance.subscribe( 'plugin/zoom/zoomLevel', @@ -64,6 +122,9 @@ export default (client, layerConf, config) => { htmlExportA.setAttribute('href', screenshot) } }) + mapInstance.subscribe('plugin/draw/featureCollection', (geojson) => { + htmlDraw.innerHTML = JSON.stringify(geojson, null, 2) + }) window.mapInstance = mapInstance }) diff --git a/packages/clients/diplan/example/style.css b/packages/clients/diplan/example/style.css index c5d952959..1699afba8 100644 --- a/packages/clients/diplan/example/style.css +++ b/packages/clients/diplan/example/style.css @@ -92,6 +92,14 @@ h2 { border-bottom: 2px solid #2b3980; } +#subscribed-draw, #subscribed-gfi { + display: block; + max-width: 600px; + max-height: 400px; + white-space: pre-wrap; + overflow-y: auto; +} + footer { color: #ecf4ff; background: #2b3980; diff --git a/packages/clients/diplan/src/polar-client.ts b/packages/clients/diplan/src/polar-client.ts index 04fb3b613..e6f78fb74 100644 --- a/packages/clients/diplan/src/polar-client.ts +++ b/packages/clients/diplan/src/polar-client.ts @@ -62,6 +62,7 @@ polarCore.addPlugins([ AddressSearch({ addLoading: 'plugin/loadingIndicator/addLoadingKey', removeLoading: 'plugin/loadingIndicator/removeLoadingKey', + layoutTag: NineLayoutTag.TOP_LEFT, // must be overridden by client-specific configuration searchMethods: [], }), From ffeca1736ab8ff3797a34e98b53961fab3a36c19 Mon Sep 17 00:00:00 2001 From: Dennis Sen Date: Fri, 14 Feb 2025 12:14:25 +0100 Subject: [PATCH 2/3] add missing example copy for prod mode --- packages/clients/diplan/example/prod-example.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/clients/diplan/example/prod-example.html b/packages/clients/diplan/example/prod-example.html index 02c9df30a..f1d95b157 100644 --- a/packages/clients/diplan/example/prod-example.html +++ b/packages/clients/diplan/example/prod-example.html @@ -15,6 +15,20 @@

Testseite @polar/client-diplan (build)

Beispielinstanz

+
+

Steuerung von außen

+ + + + + + +
+
+

Klient

From 7372ddc40048376beec15913e9210e5f7720d07f Mon Sep 17 00:00:00 2001 From: Dennis Sen Date: Mon, 17 Feb 2025 06:32:05 +0100 Subject: [PATCH 3/3] rename global diplan client to technical name --- packages/clients/diplan/example/prod-example.html | 6 +++--- packages/clients/diplan/vite.config.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/clients/diplan/example/prod-example.html b/packages/clients/diplan/example/prod-example.html index 8f01efd3f..af873978a 100644 --- a/packages/clients/diplan/example/prod-example.html +++ b/packages/clients/diplan/example/prod-example.html @@ -81,16 +81,16 @@

Informationen aus Kartenklient

At solmen va esser necessi far uniform grammatica, pronunciation e plu sommun paroles.
- + - + diff --git a/packages/clients/diplan/vite.config.js b/packages/clients/diplan/vite.config.js index b0499fa58..e84d5109e 100644 --- a/packages/clients/diplan/vite.config.js +++ b/packages/clients/diplan/vite.config.js @@ -4,7 +4,7 @@ export default getClientConfig({ root: 'example', build: { lib: { - name: 'MapClient', + name: 'PolarClientDiPlan', entry: '../src/polar-client.ts', fileName: () => 'polar-client.js', },