Skip to content

Commit 4b651d8

Browse files
authored
Merge branch 'main' into feature/add-snapTo-mode-to-draw
2 parents e737296 + ea6f796 commit 4b651d8

File tree

7 files changed

+109
-10
lines changed

7 files changed

+109
-10
lines changed

packages/clients/diplan/example/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default {
3333
// TODO should we provide english locales?
3434
],
3535
addressSearch: {
36+
displayComponent: true,
3637
searchMethods: [
3738
{
3839
queryParameters: {

packages/clients/diplan/example/index.html

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,20 @@ <h1>Testseite <code>@polar/client-diplan</code> (dev)</h1>
1515
<main>
1616
<section>
1717
<h2 class="padded-x">Beispielinstanz</h2>
18+
<div class="padded-x">
19+
<h3>Steuerung von außen</h3>
20+
<button id="action-plus">+</button>
21+
<button id="action-minus">-</button>
22+
<button id="action-toast">Toast</button>
23+
<button id="action-load-geojson">GeoJSON hinzufügen</button>
24+
<button id="action-zoom-to-all">Zoome auf Zeichnung</button>
25+
<label>
26+
Adresssuche (erstbestes Ergebnis):
27+
<input id="action-address-search-filler"/>
28+
</label>
29+
<br/>
30+
</div>
31+
<h3 class="padded-x">Klient</h3>
1832
<div id="polarstern">
1933
<noscript>Bitte benutzen Sie einen Browser mit aktiviertem JavaScript, um den Kartenklienten zu nutzen.</noscript>
2034
</div>
@@ -47,9 +61,9 @@ <h2>Informationen aus Kartenklient</h2>
4761
<td>Wert der aktuellen <code>GetFeatureInformation</code>-Antwort(en) als <code>Record&lt;LayerId, Feature[]&gt;</code></td>
4862
</tr>
4963
<tr>
50-
<td><code>plugin/...</code></td>
51-
<td id="subscribed-a">uninitialized</td>
52-
<td>Text</td>
64+
<td><code>plugin/draw/featureCollection</code></td>
65+
<td id="subscribed-draw">uninitialized</td>
66+
<td>Die hergestellte Zeichnung als GeoJSON.</td>
5367
</tr>
5468
<tr>
5569
<td><code>plugin/...</code></td>

packages/clients/diplan/example/prod-example.html

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,20 @@ <h1>Testseite <code>@polar/client-diplan</code> (build)</h1>
1515
<main>
1616
<section>
1717
<h2 class="padded-x">Beispielinstanz</h2>
18+
<div class="padded-x">
19+
<h3>Steuerung von außen</h3>
20+
<button id="action-plus">+</button>
21+
<button id="action-minus">-</button>
22+
<button id="action-toast">Toast</button>
23+
<button id="action-load-geojson">GeoJSON hinzufügen</button>
24+
<button id="action-zoom-to-all">Zoome auf Zeichnung</button>
25+
<label>
26+
Adresssuche (erstbestes Ergebnis):
27+
<input id="action-address-search-filler"/>
28+
</label>
29+
<br/>
30+
</div>
31+
<h3 class="padded-x">Klient</h3>
1832
<div id="polarstern">
1933
<noscript>Bitte benutzen Sie einen Browser mit aktiviertem JavaScript, um den Kartenklienten zu nutzen.</noscript>
2034
</div>
@@ -47,9 +61,9 @@ <h2>Informationen aus Kartenklient</h2>
4761
<td>Wert der aktuellen <code>GetFeatureInformation</code>-Antwort(en) als <code>Record&lt;LayerId, Feature[]&gt;</code></td>
4862
</tr>
4963
<tr>
50-
<td><code>plugin/...</code></td>
51-
<td id="subscribed-a">uninitialized</td>
52-
<td>Text</td>
64+
<td><code>plugin/draw/featureCollection</code></td>
65+
<td id="subscribed-draw">uninitialized</td>
66+
<td>Die hergestellte Zeichnung als GeoJSON.</td>
5367
</tr>
5468
<tr>
5569
<td><code>plugin/...</code></td>
@@ -81,16 +95,16 @@ <h2>Informationen aus Kartenklient</h2>
8195
</section>
8296
</main>
8397
<footer>At solmen va esser necessi far uniform grammatica, pronunciation e plu sommun paroles.</footer>
84-
<!-- Example without build tools. Most frameworks will allow importing this. (Try "* as MapClient".) -->
98+
<!-- Example without build tools. Most frameworks will allow importing this. (Try "* as PolarClientDiPlan".) -->
8599
<script src="../dist/polar-client.js"></script>
86-
<!-- → window.MapClient is now available. TODO: Choose a better name. -->
100+
<!-- → window.PolarClientDiPlan is now available. -->
87101
<link rel="stylesheet" src="../dist/polar-client.css">
88102
<script type="module">
89103
import services from './services.js'
90104
import config from './config.js'
91105

92106
import setup from './setup.js'
93-
setup(MapClient, services, config)
107+
setup(PolarClientDiPlan, services, config)
94108
</script>
95109
</body>
96110
</html>

packages/clients/diplan/example/setup.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
/* eslint-disable max-lines-per-function */
22

3+
const geoJSON = {
4+
type: 'FeatureCollection',
5+
features: [
6+
{
7+
type: 'Feature',
8+
properties: {},
9+
geometry: {
10+
type: 'Polygon',
11+
coordinates: [
12+
[
13+
[553702.4519707427, 5926504.665153537],
14+
[549799.849911481, 5938873.929307467],
15+
[582674.3113259386, 5942313.510783426],
16+
[572421.7126956752, 5930142.68402234],
17+
[553702.4519707427, 5926504.665153537],
18+
],
19+
],
20+
},
21+
},
22+
],
23+
}
24+
325
/* this is an example setup function displaying how POLAR is instantiated
426
* you may do this in any other format as long as all required contents arrive
527
* in `initializeLayerList` and `createMap` */
@@ -40,10 +62,46 @@ export default (client, layerConf, config) => {
4062

4163
// TODO expand example bindings
4264

65+
const actionPlus = document.getElementById('action-plus')
66+
const actionMinus = document.getElementById('action-minus')
67+
const actionToast = document.getElementById('action-toast')
68+
const actionLoadGeoJson = document.getElementById('action-load-geojson')
69+
const actionZoomToAll = document.getElementById('action-zoom-to-all')
70+
const actionFillAddressSearch = document.getElementById(
71+
'action-address-search-filler'
72+
)
73+
74+
actionPlus.onclick = () =>
75+
mapInstance.$store.dispatch('plugin/zoom/increaseZoomLevel')
76+
actionMinus.onclick = () =>
77+
mapInstance.$store.dispatch('plugin/zoom/decreaseZoomLevel')
78+
actionToast.onclick = () =>
79+
mapInstance.$store.dispatch('plugin/toast/addToast', {
80+
type: 'success',
81+
text: 'Dies ist eine Beispielnachricht.',
82+
timeout: 3000,
83+
})
84+
actionLoadGeoJson.onclick = () => {
85+
mapInstance.$store.dispatch('plugin/draw/addFeatures', {
86+
geoJSON,
87+
})
88+
}
89+
actionZoomToAll.onclick = () =>
90+
mapInstance.$store.dispatch('plugin/draw/zoomToAllFeatures', {
91+
margin: 10, // defaults to 20
92+
})
93+
actionFillAddressSearch.addEventListener('input', (e) =>
94+
mapInstance.$store.dispatch('plugin/addressSearch/search', {
95+
input: e.target.value,
96+
autoselect: 'first',
97+
})
98+
)
99+
43100
const htmlZoom = document.getElementById('subscribed-zoom')
44101
const htmlGfi = document.getElementById('subscribed-gfi')
45102
const htmlExportA = document.getElementById('subscribed-export-a')
46103
const htmlExportImg = document.getElementById('subscribed-export-img')
104+
const htmlDraw = document.getElementById('subscribed-draw')
47105

48106
mapInstance.subscribe(
49107
'plugin/zoom/zoomLevel',
@@ -64,6 +122,9 @@ export default (client, layerConf, config) => {
64122
htmlExportA.setAttribute('href', screenshot)
65123
}
66124
})
125+
mapInstance.subscribe('plugin/draw/featureCollection', (geojson) => {
126+
htmlDraw.innerHTML = JSON.stringify(geojson, null, 2)
127+
})
67128

68129
window.mapInstance = mapInstance
69130
})

packages/clients/diplan/example/style.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ h2 {
9292
border-bottom: 2px solid #2b3980;
9393
}
9494

95+
#subscribed-draw, #subscribed-gfi {
96+
display: block;
97+
max-width: 600px;
98+
max-height: 400px;
99+
white-space: pre-wrap;
100+
overflow-y: auto;
101+
}
102+
95103
footer {
96104
color: #ecf4ff;
97105
background: #2b3980;

packages/clients/diplan/src/polar-client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ polarCore.addPlugins([
6868
AddressSearch({
6969
addLoading: 'plugin/loadingIndicator/addLoadingKey',
7070
removeLoading: 'plugin/loadingIndicator/removeLoadingKey',
71+
layoutTag: NineLayoutTag.TOP_LEFT,
7172
// must be overridden by client-specific configuration
7273
searchMethods: [],
7374
}),

packages/clients/diplan/vite.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default getClientConfig({
44
root: 'example',
55
build: {
66
lib: {
7-
name: 'MapClient',
7+
name: 'PolarClientDiPlan',
88
entry: '../src/polar-client.ts',
99
fileName: () => 'polar-client.js',
1010
},

0 commit comments

Comments
 (0)