Skip to content

Commit

Permalink
Merge branch 'main' into feature/add-snapTo-mode-to-draw
Browse files Browse the repository at this point in the history
  • Loading branch information
warm-coolguy authored Feb 17, 2025
2 parents e737296 + ea6f796 commit 4b651d8
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 10 deletions.
1 change: 1 addition & 0 deletions packages/clients/diplan/example/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default {
// TODO should we provide english locales?
],
addressSearch: {
displayComponent: true,
searchMethods: [
{
queryParameters: {
Expand Down
20 changes: 17 additions & 3 deletions packages/clients/diplan/example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ <h1>Testseite <code>@polar/client-diplan</code> (dev)</h1>
<main>
<section>
<h2 class="padded-x">Beispielinstanz</h2>
<div class="padded-x">
<h3>Steuerung von außen</h3>
<button id="action-plus">+</button>
<button id="action-minus">-</button>
<button id="action-toast">Toast</button>
<button id="action-load-geojson">GeoJSON hinzufügen</button>
<button id="action-zoom-to-all">Zoome auf Zeichnung</button>
<label>
Adresssuche (erstbestes Ergebnis):
<input id="action-address-search-filler"/>
</label>
<br/>
</div>
<h3 class="padded-x">Klient</h3>
<div id="polarstern">
<noscript>Bitte benutzen Sie einen Browser mit aktiviertem JavaScript, um den Kartenklienten zu nutzen.</noscript>
</div>
Expand Down Expand Up @@ -47,9 +61,9 @@ <h2>Informationen aus Kartenklient</h2>
<td>Wert der aktuellen <code>GetFeatureInformation</code>-Antwort(en) als <code>Record&lt;LayerId, Feature[]&gt;</code></td>
</tr>
<tr>
<td><code>plugin/...</code></td>
<td id="subscribed-a">uninitialized</td>
<td>Text</td>
<td><code>plugin/draw/featureCollection</code></td>
<td id="subscribed-draw">uninitialized</td>
<td>Die hergestellte Zeichnung als GeoJSON.</td>
</tr>
<tr>
<td><code>plugin/...</code></td>
Expand Down
26 changes: 20 additions & 6 deletions packages/clients/diplan/example/prod-example.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ <h1>Testseite <code>@polar/client-diplan</code> (build)</h1>
<main>
<section>
<h2 class="padded-x">Beispielinstanz</h2>
<div class="padded-x">
<h3>Steuerung von außen</h3>
<button id="action-plus">+</button>
<button id="action-minus">-</button>
<button id="action-toast">Toast</button>
<button id="action-load-geojson">GeoJSON hinzufügen</button>
<button id="action-zoom-to-all">Zoome auf Zeichnung</button>
<label>
Adresssuche (erstbestes Ergebnis):
<input id="action-address-search-filler"/>
</label>
<br/>
</div>
<h3 class="padded-x">Klient</h3>
<div id="polarstern">
<noscript>Bitte benutzen Sie einen Browser mit aktiviertem JavaScript, um den Kartenklienten zu nutzen.</noscript>
</div>
Expand Down Expand Up @@ -47,9 +61,9 @@ <h2>Informationen aus Kartenklient</h2>
<td>Wert der aktuellen <code>GetFeatureInformation</code>-Antwort(en) als <code>Record&lt;LayerId, Feature[]&gt;</code></td>
</tr>
<tr>
<td><code>plugin/...</code></td>
<td id="subscribed-a">uninitialized</td>
<td>Text</td>
<td><code>plugin/draw/featureCollection</code></td>
<td id="subscribed-draw">uninitialized</td>
<td>Die hergestellte Zeichnung als GeoJSON.</td>
</tr>
<tr>
<td><code>plugin/...</code></td>
Expand Down Expand Up @@ -81,16 +95,16 @@ <h2>Informationen aus Kartenklient</h2>
</section>
</main>
<footer>At solmen va esser necessi far uniform grammatica, pronunciation e plu sommun paroles.</footer>
<!-- Example without build tools. Most frameworks will allow importing this. (Try "* as MapClient".) -->
<!-- Example without build tools. Most frameworks will allow importing this. (Try "* as PolarClientDiPlan".) -->
<script src="../dist/polar-client.js"></script>
<!-- → window.MapClient is now available. TODO: Choose a better name. -->
<!-- → window.PolarClientDiPlan is now available. -->
<link rel="stylesheet" src="../dist/polar-client.css">
<script type="module">
import services from './services.js'
import config from './config.js'

import setup from './setup.js'
setup(MapClient, services, config)
setup(PolarClientDiPlan, services, config)
</script>
</body>
</html>
61 changes: 61 additions & 0 deletions packages/clients/diplan/example/setup.js
Original file line number Diff line number Diff line change
@@ -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` */
Expand Down Expand Up @@ -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',
Expand All @@ -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
})
Expand Down
8 changes: 8 additions & 0 deletions packages/clients/diplan/example/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions packages/clients/diplan/src/polar-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ polarCore.addPlugins([
AddressSearch({
addLoading: 'plugin/loadingIndicator/addLoadingKey',
removeLoading: 'plugin/loadingIndicator/removeLoadingKey',
layoutTag: NineLayoutTag.TOP_LEFT,
// must be overridden by client-specific configuration
searchMethods: [],
}),
Expand Down
2 changes: 1 addition & 1 deletion packages/clients/diplan/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default getClientConfig({
root: 'example',
build: {
lib: {
name: 'MapClient',
name: 'PolarClientDiPlan',
entry: '../src/polar-client.ts',
fileName: () => 'polar-client.js',
},
Expand Down

0 comments on commit 4b651d8

Please sign in to comment.