@vcmap/ui 5.0.0-rc.14 → 5.0.0-rc.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/README.md +33 -31
  2. package/build/build.js +9 -0
  3. package/build/buildHelpers.js +12 -10
  4. package/build/commonViteConfig.js +3 -10
  5. package/config/base.config.json +26 -24
  6. package/config/dev.config.json +8 -0
  7. package/config/www.config.json +102 -17
  8. package/dist/assets/cesium.2e288a.js +137226 -0
  9. package/dist/assets/cesium.js +1 -1
  10. package/dist/assets/core.8014d3.js +14473 -0
  11. package/dist/assets/core.js +1 -1
  12. package/dist/assets/index.3f74fa92.js +1 -0
  13. package/dist/assets/ol.31c3a5.js +44279 -0
  14. package/dist/assets/ol.js +1 -1
  15. package/dist/assets/ui.36f84f.css +1 -0
  16. package/dist/assets/ui.36f84f.js +16101 -0
  17. package/dist/assets/ui.js +1 -1
  18. package/dist/assets/vue.a39c10.js +4675 -0
  19. package/dist/assets/vue.js +5 -2
  20. package/dist/assets/{vuetify.202322.css → vuetify.378637.css} +1 -1
  21. package/dist/assets/vuetify.378637.js +21019 -0
  22. package/dist/assets/vuetify.js +5 -2
  23. package/dist/index.html +1 -1
  24. package/index.js +4 -1
  25. package/package.json +10 -10
  26. package/plugins/@vcmap/pluginExample/index.js +14 -0
  27. package/plugins/@vcmap/pluginExample/pluginExampleComponent.vue +93 -67
  28. package/plugins/@vcmap/project-selector/ContextsListComponent.vue +8 -1
  29. package/plugins/@vcmap/project-selector/ProjectSelectorComponent.vue +27 -1
  30. package/plugins/@vcmap/search-nominatim/LICENSE.md +14 -0
  31. package/plugins/@vcmap/search-nominatim/README.md +2 -0
  32. package/plugins/@vcmap/search-nominatim/config.json +4 -0
  33. package/plugins/@vcmap/search-nominatim/index.js +26 -0
  34. package/plugins/@vcmap/search-nominatim/nominatim.js +170 -0
  35. package/plugins/@vcmap/search-nominatim/package.json +43 -0
  36. package/plugins/@vcmap/theme-changer/ThemeChangerComponent.vue +24 -0
  37. package/plugins/buttonExamples/ButtonExamples.vue +28 -1
  38. package/plugins/categoryTest/Categories.vue +16 -0
  39. package/plugins/categoryTest/Category.vue +30 -4
  40. package/plugins/example/mySuperComponent.vue +12 -1
  41. package/plugins/package.json +2 -1
  42. package/plugins/simple-graph/SimpleGraphComponent.vue +5 -11
  43. package/plugins/test/allIconsComponent.vue +16 -0
  44. package/plugins/test/editor.vue +3 -0
  45. package/plugins/test/emptyComponent.vue +3 -0
  46. package/plugins/test/vcsContent.vue +3 -0
  47. package/src/actions/actionHelper.js +103 -2
  48. package/src/actions/styleSelector.vue +9 -0
  49. package/src/application/VcsApp.vue +77 -9
  50. package/src/application/VcsAttributions.vue +63 -0
  51. package/src/application/VcsAttributionsFooter.vue +87 -0
  52. package/src/application/{Navbar.vue → VcsNavbar.vue} +35 -2
  53. package/src/application/VcsSettings.vue +4 -0
  54. package/src/application/attributionsHelper.js +150 -0
  55. package/src/application/vcsAppWrapper.vue +5 -1
  56. package/src/components/buttons/VcsActionButtonList.vue +8 -1
  57. package/src/components/buttons/VcsButton.vue +7 -1
  58. package/src/components/form-inputs-controls/VcsCheckbox.vue +7 -2
  59. package/src/components/form-inputs-controls/VcsColorPicker.vue +4 -0
  60. package/src/components/form-inputs-controls/VcsFormSection.vue +48 -2
  61. package/src/components/form-inputs-controls/VcsRadio.vue +7 -1
  62. package/src/components/form-inputs-controls/VcsSelect.vue +5 -1
  63. package/src/components/form-inputs-controls/VcsTextArea.vue +2 -0
  64. package/src/components/form-inputs-controls/VcsTextField.vue +6 -2
  65. package/src/components/lists/VcsActionList.vue +12 -1
  66. package/src/components/lists/VcsTreeview.vue +6 -1
  67. package/src/components/lists/VcsTreeviewLeaf.vue +5 -1
  68. package/src/components/lists/VcsTreeviewSearchbar.vue +5 -0
  69. package/src/components/notification/VcsTooltip.vue +14 -9
  70. package/src/components/tables/VcsTable.vue +117 -38
  71. package/src/featureInfo/AddressBalloonComponent.vue +17 -1
  72. package/src/featureInfo/BalloonComponent.vue +57 -23
  73. package/src/featureInfo/balloonFeatureInfoView.js +2 -2
  74. package/src/featureInfo/featureInfo.js +10 -2
  75. package/src/i18n/de.js +15 -0
  76. package/src/i18n/en.js +15 -0
  77. package/src/legend/legendHelper.js +18 -12
  78. package/src/legend/styleLegendItem.vue +20 -1
  79. package/src/legend/vcsLegend.vue +29 -3
  80. package/src/manager/toolbox/GroupToolboxComponent.vue +13 -1
  81. package/src/manager/toolbox/SelectToolboxComponent.vue +13 -1
  82. package/src/manager/toolbox/ToolboxManager.vue +3 -0
  83. package/src/manager/window/WindowComponent.vue +6 -0
  84. package/src/manager/window/WindowComponentHeader.vue +6 -1
  85. package/src/navigation/mapNavigation.vue +15 -36
  86. package/src/navigation/orientationToolsButton.vue +6 -1
  87. package/src/navigation/overviewMap.js +10 -39
  88. package/src/navigation/tiltSlider.vue +3 -0
  89. package/src/navigation/vcsCompass.vue +2 -0
  90. package/src/search/resultItem.vue +89 -0
  91. package/src/search/resultsComponent.vue +98 -0
  92. package/src/search/search.js +326 -0
  93. package/src/search/searchComponent.vue +90 -0
  94. package/src/styles/_typography.scss +3 -0
  95. package/src/styles/utils/_cursor.scss +4 -0
  96. package/src/styles/variables.scss +4 -1
  97. package/src/vcsUiApp.js +16 -0
  98. package/dist/assets/cesium.9489f8.js +0 -8699
  99. package/dist/assets/core.aa346a.js +0 -4
  100. package/dist/assets/index.3cd4fffa.js +0 -1
  101. package/dist/assets/ol.39651b.js +0 -439
  102. package/dist/assets/ui.15ef6a.css +0 -1
  103. package/dist/assets/ui.15ef6a.js +0 -71
  104. package/dist/assets/vue.cbe9d8.js +0 -9
  105. package/dist/assets/vuetify.202322.js +0 -148
@@ -1,2 +1,5 @@
1
- export * from "./vuetify.202322.js";
2
- export { default } from "./vuetify.202322.js";
1
+ export * from "./vuetify.378637.js";
2
+ import { default as f } from "./vuetify.378637.js";
3
+ export {
4
+ f as default
5
+ };
package/dist/index.html CHANGED
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="utf-8" />
5
5
  <meta name="viewport" content="width=device-width,initial-scale=1.0" />
6
- <script type="module" crossorigin src="./assets/index.3cd4fffa.js"></script>
6
+ <script type="module" crossorigin src="./assets/index.3f74fa92.js"></script>
7
7
  </head>
8
8
  <body style="height: 100vH;">
9
9
  <noscript>
package/index.js CHANGED
@@ -9,12 +9,13 @@ export {
9
9
  createModalAction,
10
10
  createLinkAction,
11
11
  createGoToViewpointAction,
12
+ createZoomToFeatureAction,
12
13
  } from './src/actions/actionHelper.js';
13
14
  export {
14
15
  createStateRefAction,
15
16
  } from './src/actions/stateRefAction.js';
16
17
 
17
- export { default as Navbar } from './src/application/Navbar.vue';
18
+ export { default as VcsNavbar } from './src/application/VcsNavbar.vue';
18
19
  export {
19
20
  default as VcsApp,
20
21
  setupMapNavbar,
@@ -68,11 +69,13 @@ export { default as ContextMenuInteraction } from './src/manager/contextMenu/con
68
69
 
69
70
  export { applyKeyMapping, applyValueMapping, default as AbstractFeatureInfoView } from './src/featureInfo/abstractFeatureInfoView.js';
70
71
  export { extractNestedKey, default as BalloonFeatureInfoView } from './src/featureInfo/balloonFeatureInfoView.js';
72
+ export { default as AddressBalloonFeatureInfoView } from './src/featureInfo/addressBalloonFeatureInfoView.js';
71
73
  export { getBalloonPosition, setBalloonPosition, setupBalloonPositionListener } from './src/featureInfo/balloonHelper.js';
72
74
  export { default as BalloonComponent } from './src/featureInfo/BalloonComponent.vue';
73
75
  export { default as AddressBalloonComponent } from './src/featureInfo/AddressBalloonComponent.vue';
74
76
  export { default as IframeFeatureInfoView } from './src/featureInfo/iframeFeatureInfoView.js';
75
77
  export { default as TableFeatureInfoView } from './src/featureInfo/tableFeatureInfoView.js';
78
+ export { getHighlightStyle, featureInfoViewSymbol } from './src/featureInfo/featureInfo.js';
76
79
 
77
80
  export { default as MapNavCompass } from './src/navigation/mapNavCompass.vue';
78
81
  export { default as MapNavigation } from './src/navigation/mapNavigation.vue';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vcmap/ui",
3
- "version": "5.0.0-rc.14",
3
+ "version": "5.0.0-rc.15",
4
4
  "author": "Virtual City Systems",
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -42,29 +42,28 @@
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@vcmap/cesium": "~1.97.1",
45
- "@vcmap/core": "~5.0.0-rc.22",
45
+ "@vcmap/core": "~5.0.0-rc.23",
46
46
  "ol": "~7.1.0",
47
47
  "vue": "~2.7.3",
48
48
  "vuetify": "~2.6.7"
49
49
  },
50
50
  "devDependencies": {
51
- "@vcmap/rollup-plugin-vcs-ol": "^1.0.1",
51
+ "@vcmap/rollup-plugin-vcs-ol": "^1.0.2",
52
52
  "@vcsuite/eslint-config": "^2.1.1",
53
- "c8": "^7.11.0",
53
+ "@vitest/coverage-c8": "^0.24.3",
54
54
  "eslint": "^8.9.0",
55
55
  "eslint-import-resolver-alias": "^1.1.2",
56
- "jest-canvas-mock": "^2.3.1",
56
+ "jest-canvas-mock": "^2.4.0",
57
57
  "jsdoc": "^3.6.7",
58
- "jsdoc-plugin-typescript": "^2.0.6",
59
58
  "jsdoc-plugin-intersection": "^1.0.4",
59
+ "jsdoc-plugin-typescript": "^2.0.6",
60
60
  "jsdom": "^19.0.0",
61
61
  "rollup-plugin-strip-pragma": "^1.0.0",
62
62
  "sass": "1.32.13",
63
63
  "typescript": "^4.2.4",
64
- "unplugin-vue-components": "^0.21.1",
65
- "vite": "^2.9.13",
66
- "vite-plugin-vue2": "^2.0.1",
67
- "vitest": "^0.14.2"
64
+ "vite": "^3.2.0",
65
+ "vite-plugin-vue2": "^2.0.2",
66
+ "vitest": "^0.24.3"
68
67
  },
69
68
  "stylelint": {
70
69
  "extends": "stylelint-config-standard",
@@ -128,6 +127,7 @@
128
127
  "./config/*.json": "./config/*.json",
129
128
  "./src/assets/logo.svg": "./src/assets/logo.svg",
130
129
  "./src/assets/logo-mobile.svg": "./src/assets/logo-mobile.svg",
130
+ "./build/commonViteConfig.js": "./build/commonViteConfig.js",
131
131
  "./build/buildHelpers.js": "./build/buildHelpers.js",
132
132
  "./build/getPluginProxies.js": "./build/getPluginProxies.js",
133
133
  "./build/determineHost.js": "./build/determineHost.js",
@@ -187,6 +187,13 @@ export default function (config) {
187
187
  title: 'Plugin Beispiel',
188
188
  select: 'Select Feld',
189
189
  tooltip: 'Beispiel Plugin Map Button Tooltip',
190
+ help: 'Geben Sie eine Zahl in das Feld NumberInput ein. VcsFormattedNumber rundet auf eine Dezimalstelle.',
191
+ help1: 'Wählen Sie eine Option',
192
+ help1desc: 'Wenn \'Option A\' gewählt ist, muss der bedingte Input \'test\' sein.',
193
+ help2: 'Ändern Sie den Wert von \'myInitialText\'',
194
+ help2desc: 'InitialTextInput bleibt solange im Lade-Status, bis sich der Wert \'myInitialText\' ändert.',
195
+ help3: 'Geben Sie eine Email Adresse ein',
196
+ help3desc: 'Email Adressen werden validiert.',
190
197
  },
191
198
  },
192
199
  en: {
@@ -194,6 +201,13 @@ export default function (config) {
194
201
  title: 'Plugin Example',
195
202
  select: 'Select field',
196
203
  tooltip: 'Example Plugin Map Button Tooltip',
204
+ help: 'Enter a number to the NumberInput field. VcsFormattedNumber rounds to one decimal digit.',
205
+ help1: 'Select an option',
206
+ help1desc: 'If \'Option A\' is chosen, conditional input must be \'test\'.',
207
+ help2: 'Change \'myInitialText\' to some other value',
208
+ help2desc: 'InitialTextInput text field stays in loading state, as long as \'myInitialText\' is not changed.',
209
+ help3: 'Enter an email address.',
210
+ help3desc: 'Emails get validated.',
197
211
  },
198
212
  },
199
213
  },
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <v-form v-model="isValid">
3
3
  <VcsFormSection
4
- title="VcsFormSection"
4
+ title="VcsFormSection Select & Text Inputs"
5
5
  :title-actions="[
6
6
  {
7
7
  name: 'denseSelection',
@@ -10,12 +10,6 @@
10
10
  callback: () => this.dense = !this.dense
11
11
  },
12
12
  { name: 'noIcon', title: 'another action without icon', callback: () => {} },
13
- {
14
- name: 'help',
15
- title: helpExample,
16
- icon: 'mdi-help-circle',
17
- callback: () => {},
18
- },
19
13
  {
20
14
  name: 'toggleSection',
21
15
  title: 'toggle section',
@@ -32,6 +26,16 @@
32
26
  { name: 'alert', icon: 'mdi-message-text', callback: alertAction },
33
27
  ]"
34
28
  >
29
+ <template #help>
30
+ <ol>
31
+ <li>{{ $t('pluginExample.help1') }}:</li>
32
+ <span>{{ $t('pluginExample.help1desc') }}</span>
33
+ <li>{{ $t('pluginExample.help2') }}:</li>
34
+ <span>{{ $t('pluginExample.help2desc') }}</span>
35
+ <li>{{ $t('pluginExample.help3') }}:</li>
36
+ <span>{{ $t('pluginExample.help3desc') }}</span>
37
+ </ol>
38
+ </template>
35
39
  <template #default v-if="showSection">
36
40
  <v-container class="pa-2">
37
41
  <v-row
@@ -107,6 +111,35 @@
107
111
  />
108
112
  </v-col>
109
113
  </v-row>
114
+ <v-row
115
+ :dense="dense"
116
+ no-gutters
117
+ align="center"
118
+ >
119
+ <v-col>
120
+ <VcsLabel html-for="emailInput" :dense="dense">
121
+ Email
122
+ </VcsLabel>
123
+ </v-col>
124
+ <v-col>
125
+ <VcsTextField
126
+ id="emailInput"
127
+ :dense="dense"
128
+ type="email"
129
+ :rules="[isValidEmail]"
130
+ v-model="state.email"
131
+ />
132
+ </v-col>
133
+ </v-row>
134
+ </v-container>
135
+ </template>
136
+ </VcsFormSection>
137
+ <VcsFormSection
138
+ title="VcsFormSection Number Inputs"
139
+ help-text="pluginExample.help"
140
+ >
141
+ <template #default>
142
+ <v-container>
110
143
  <v-row
111
144
  :dense="dense"
112
145
  no-gutters
@@ -199,58 +232,14 @@
199
232
  />
200
233
  </v-col>
201
234
  </v-row>
202
- <v-row
203
- :dense="dense"
204
- no-gutters
205
- align="center"
206
- >
207
- <v-col cols="1" class="px-1">
208
- <VcsLabel html-for="textInput" :dense="dense" class="text-caption">
209
- 1
210
- </VcsLabel>
211
- </v-col>
212
- <v-col>
213
- <VcsSelect
214
- :items="['A', 'B', 'C']"
215
- :dense="dense"
216
- />
217
- </v-col>
218
- <v-col>
219
- <VcsSelect
220
- :items="['A', 'B', 'C']"
221
- :dense="dense"
222
- multiple
223
- />
224
- </v-col>
225
- <v-col>
226
- <VcsTextField
227
- id="textInput"
228
- clearable
229
- :dense="dense"
230
- v-model="state.conditionalInput"
231
- />
232
- </v-col>
233
- </v-row>
234
- <v-row
235
- :dense="dense"
236
- no-gutters
237
- align="center"
238
- >
239
- <v-col>
240
- <VcsLabel html-for="emailInput" :dense="dense">
241
- Email
242
- </VcsLabel>
243
- </v-col>
244
- <v-col>
245
- <VcsTextField
246
- id="emailInput"
247
- :dense="dense"
248
- type="email"
249
- :rules="[isValidEmail]"
250
- v-model="state.email"
251
- />
252
- </v-col>
253
- </v-row>
235
+ </v-container>
236
+ </template>
237
+ </VcsFormSection>
238
+ <VcsFormSection
239
+ title="VcsFormSection Radio & Checkbox"
240
+ >
241
+ <template #default>
242
+ <v-container>
254
243
  <v-row
255
244
  :dense="dense"
256
245
  no-gutters
@@ -296,6 +285,46 @@
296
285
  </v-container>
297
286
  </template>
298
287
  </vcsformsection>
288
+ <VcsFormSection
289
+ title="VcsFormSection Mixed Inputs"
290
+ >
291
+ <template #default>
292
+ <v-container>
293
+ <v-row
294
+ :dense="dense"
295
+ no-gutters
296
+ align="center"
297
+ >
298
+ <v-col cols="1" class="px-1">
299
+ <VcsLabel html-for="textInput" :dense="dense" class="text-caption">
300
+ 1
301
+ </VcsLabel>
302
+ </v-col>
303
+ <v-col>
304
+ <VcsSelect
305
+ :items="['A', 'B', 'C']"
306
+ :dense="dense"
307
+ />
308
+ </v-col>
309
+ <v-col>
310
+ <VcsSelect
311
+ :items="['A', 'B', 'C']"
312
+ :dense="dense"
313
+ multiple
314
+ />
315
+ </v-col>
316
+ <v-col>
317
+ <VcsTextField
318
+ id="textInput"
319
+ clearable
320
+ :dense="dense"
321
+ v-model="state.conditionalInput"
322
+ />
323
+ </v-col>
324
+ </v-row>
325
+ </v-container>
326
+ </template>
327
+ </VcsFormSection>
299
328
  <VcsButton
300
329
  @click="logState(state)"
301
330
  :disabled="!isValid"
@@ -325,6 +354,7 @@
325
354
  VcsFormSection,
326
355
  VcsLabel,
327
356
  } from '@vcmap/ui';
357
+ import { VCol, VContainer, VForm, VRow } from 'vuetify/lib';
328
358
  import { isValidText, conditionalTest, isValidEmail } from './validation.js';
329
359
 
330
360
  export default {
@@ -338,6 +368,10 @@
338
368
  VcsFormattedNumber,
339
369
  VcsFormSection,
340
370
  VcsLabel,
371
+ VForm,
372
+ VRow,
373
+ VCol,
374
+ VContainer,
341
375
  },
342
376
  props: {
343
377
  windowId: {
@@ -351,17 +385,9 @@
351
385
  const newUpdate = ref(true);
352
386
  watch(plugin.state, () => { newUpdate.value = true; });
353
387
 
354
- const helpExample = [
355
- 'Please select an option.',
356
- 'If Option A is chosen, input of ConditionalInput must be \'test\'.',
357
- 'InitialTextInput stays in loading state as long as the initial text is not changed.',
358
- 'VcsFormattedNumber rounds the NumberInput to one decimal digit.',
359
- ].join('\n');
360
-
361
388
  return {
362
389
  showSection: ref(true),
363
390
  dense: ref(true),
364
- helpExample,
365
391
  // no object-destruction of reactive objects! or use toRef()
366
392
  state: plugin.state,
367
393
  // do not put the whole config here, since it would become reactive
@@ -33,10 +33,17 @@
33
33
 
34
34
  <script>
35
35
  import { VcsTooltip } from '@vcmap/ui';
36
+ import { VChip, VContainer, VIcon, VList } from 'vuetify/lib';
36
37
 
37
38
  export default {
38
39
  name: 'ContextsListComponent',
39
- components: { VcsTooltip },
40
+ components: {
41
+ VcsTooltip,
42
+ VContainer,
43
+ VList,
44
+ VChip,
45
+ VIcon,
46
+ },
40
47
  props: {
41
48
  contexts: {
42
49
  type: Array,
@@ -47,11 +47,37 @@
47
47
  </template>
48
48
  <script>
49
49
  import { inject } from 'vue';
50
+ import {
51
+ VList,
52
+ VContainer,
53
+ VCard,
54
+ VIcon,
55
+ VListItem,
56
+ VListItemContent,
57
+ VListItemTitle,
58
+ VListItemSubtitle,
59
+ VListItemAction,
60
+ VAvatar,
61
+ VDivider,
62
+ } from 'vuetify/lib';
50
63
  import ContextsListComponent from './ContextsListComponent.vue';
51
64
 
52
65
  export default {
53
66
  name: 'ProjectSelector',
54
- components: { ContextsListComponent },
67
+ components: {
68
+ ContextsListComponent,
69
+ VList,
70
+ VContainer,
71
+ VCard,
72
+ VIcon,
73
+ VListItem,
74
+ VListItemContent,
75
+ VListItemTitle,
76
+ VListItemSubtitle,
77
+ VListItemAction,
78
+ VAvatar,
79
+ VDivider,
80
+ },
55
81
  setup() {
56
82
  const app = inject('vcsApp');
57
83
  const plugin = app.plugins.getByKey('@vcmap/project-selector');
@@ -0,0 +1,14 @@
1
+
2
+ Copyright 2022 support@vc.systems
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5
+ documentation files (the "Software"), to deal in the Software without restriction, including without limitation
6
+ the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
7
+ and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
+
9
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
12
+ THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
13
+ OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
14
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,2 @@
1
+ # @vcmap/search-nominatim
2
+ describe your plugin
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "@vcmap/search-nominatim",
3
+
4
+ }
@@ -0,0 +1,26 @@
1
+ import { version, name } from './package.json';
2
+ import Nominatim from './nominatim.js';
3
+
4
+
5
+ /**
6
+ * @param {NominatimSearchOptions} config - the configuration of this plugin instance, passed in from the app.
7
+ * @returns {import("@vcmap/ui/src/vcsUiApp").VcsPlugin<T>}
8
+ * @template {Object} T
9
+ * @template {Object} S
10
+ */
11
+ export default function SearchNominatim(config) {
12
+ return {
13
+ _instance: null,
14
+ _app: null,
15
+ get name() { return name; },
16
+ get version() { return version; },
17
+ /**
18
+ * @param {import("@vcmap/ui").VcsUiApp} vcsUiApp
19
+ */
20
+ initialize(vcsUiApp) {
21
+ this._instance = new Nominatim(config);
22
+ this._app = vcsUiApp;
23
+ vcsUiApp.search.add(this._instance, name);
24
+ },
25
+ };
26
+ }
@@ -0,0 +1,170 @@
1
+ import { Extent, parseGeoJSON, wgs84Projection } from '@vcmap/core';
2
+ import { AddressBalloonFeatureInfoView, featureInfoViewSymbol } from '@vcmap/ui';
3
+
4
+ /**
5
+ *
6
+ * @param {Object} item - response item from the search request
7
+ * @returns {ResultItem}
8
+ */
9
+ function createResultItem(item) {
10
+ const data = parseGeoJSON(item.geojson);
11
+ const feature = data.features[0];
12
+ feature.setProperties(item.address);
13
+ const title = item.display_name;
14
+ feature[featureInfoViewSymbol] = new AddressBalloonFeatureInfoView({
15
+ type: 'AddressBalloonFeatureInfoView',
16
+ name: 'NominatimSearchBalloon',
17
+ subtitle: '',
18
+ addressName: 'building',
19
+ street: 'road',
20
+ number: 'house_number',
21
+ city: 'city',
22
+ zip: 'postcode',
23
+ country: 'country',
24
+ });
25
+
26
+ return {
27
+ title,
28
+ feature,
29
+ };
30
+ }
31
+
32
+ /**
33
+ * @typedef {Object} NominatimSearchOptions
34
+ * @property {string} [name="Nominatim"]
35
+ * @property {string} [url="https://nominatim.openstreetmap.org/search"]
36
+ * @property {string|undefined} city
37
+ * @property {string|undefined} state
38
+ * @property {string|undefined} [countrycode="de"]
39
+ * @property {import("@vcmap/core").Extent.Options|undefined} extent
40
+ * @property {number|undefined} [limit=20]
41
+ * @api
42
+ */
43
+
44
+ /**
45
+ * @class
46
+ * @implements {SearchImpl}
47
+ */
48
+ class Nominatim {
49
+ /**
50
+ * @returns {NominatimSearchOptions}
51
+ */
52
+ static getDefaultOptions() {
53
+ return {
54
+ name: 'Nominatim',
55
+ url: 'https://nominatim.openstreetmap.org/search',
56
+ city: undefined,
57
+ state: undefined,
58
+ countrycode: 'de',
59
+ extent: undefined,
60
+ limit: 20,
61
+ };
62
+ }
63
+
64
+ /**
65
+ * @param {NominatimSearchOptions} options
66
+ */
67
+ constructor(options) {
68
+ /**
69
+ * @type {NominatimSearchOptions}
70
+ */
71
+ const defaultOptions = Nominatim.getDefaultOptions();
72
+
73
+ /** @type {string|null} */
74
+ this.name = options.name ?? defaultOptions.name;
75
+
76
+ /** @type {string|Object} */
77
+ this.url = options.url ?? defaultOptions.url;
78
+
79
+ /** @type {string|null} */
80
+ this.city = options.city ?? null;
81
+
82
+ /** @type {string|null} */
83
+ this.state = options.state ?? null;
84
+
85
+ /** @type {string} */
86
+ this.countrycode = options.countrycode ?? defaultOptions.countrycode;
87
+
88
+ /** @type {import("@vcmap/core").Extent|null} */
89
+ this.extent = options.extent ? new Extent(options.extent) : null;
90
+
91
+ /** @type {number} */
92
+ this.limit = options.limit ?? defaultOptions.limit;
93
+ /**
94
+ * @type {AbortController}
95
+ * @private
96
+ */
97
+ this._controller = new AbortController();
98
+ }
99
+
100
+ /**
101
+ * @param {string} q - search value
102
+ * @returns {Array<ResultItem>}
103
+ */
104
+ async search(q) {
105
+ const params = {
106
+ q,
107
+ countrycodes: this.countrycode,
108
+ format: 'json',
109
+ polygon_geojson: 1,
110
+ addressdetails: 1,
111
+ limit: this.limit,
112
+ };
113
+
114
+ if (this.city) {
115
+ params.q += `,${this.city}`;
116
+ }
117
+
118
+ if (this.state) {
119
+ params.q += `,${this.state}`;
120
+ }
121
+
122
+ if (this.extent) {
123
+ params.viewbox = this.extent.getCoordinatesInProjection(wgs84Projection).join(',');
124
+ params.bounded = 1;
125
+ }
126
+
127
+ const url = new URL(this.url);
128
+ url.search = new URLSearchParams(params).toString();
129
+
130
+ const { signal } = this._controller.signal;
131
+ const response = await fetch(url, { signal });
132
+ const results = await response.json();
133
+ return results.map(createResultItem);
134
+ }
135
+
136
+ abort() {
137
+ this._controller.abort();
138
+ }
139
+
140
+ toJSON() {
141
+ /**
142
+ * @type {NominatimSearchOptions}
143
+ */
144
+ const defaultOptions = Nominatim.getDefaultOptions();
145
+ const config = {};
146
+
147
+ if (this.url !== defaultOptions.url) {
148
+ config.url = this.url;
149
+ }
150
+ if (this.city !== defaultOptions.city) {
151
+ config.city = this.city;
152
+ }
153
+ if (this.state !== defaultOptions.state) {
154
+ config.state = this.state;
155
+ }
156
+ if (this.countrycode !== defaultOptions.countrycode) {
157
+ config.countrycode = this.countrycode;
158
+ }
159
+ if (this.extent && this.extent !== defaultOptions.extent) {
160
+ config.extent = this.extent.toJSON();
161
+ }
162
+ if (this.limit !== defaultOptions.limit) {
163
+ config.limit = this.limit;
164
+ }
165
+
166
+ return config;
167
+ }
168
+ }
169
+
170
+ export default Nominatim;
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@vcmap/search-nominatim",
3
+ "version": "1.0.0",
4
+ "description": "A search plugin for OSM Nominatim",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "prepublishOnly": "vcmplugin build",
8
+ "build": "vcmplugin build",
9
+ "pack": "vcmplugin pack",
10
+ "start": "vcmplugin serve",
11
+ "preview": "vcmplugin preview",
12
+ "buildStagingApp": "vcmplugin buildStagingApp",
13
+ "lint": "eslint \"{src,tests}/**/*.{js,vue}\""
14
+ },
15
+ "author": "support@vc.systems",
16
+ "license": "MIT",
17
+ "dependencies": {},
18
+ "peerDependencies": {
19
+ "@vcmap/core": "^5.0.0-rc.20"
20
+ },
21
+ "keywords": [
22
+ "vcmap",
23
+ "plugin"
24
+ ],
25
+ "files": [
26
+ "src/",
27
+ "dist/",
28
+ "plugin-assets/",
29
+ "LICENSE.md",
30
+ "README.md"
31
+ ],
32
+ "exports": {
33
+ ".": "./src/index.js",
34
+ "./dist": "./dist/index.js"
35
+ },
36
+ "eslintIgnore": [
37
+ "node_modules"
38
+ ],
39
+ "eslintConfig": {
40
+ "root": true,
41
+ "extends": "@vcsuite/eslint-config/vue"
42
+ }
43
+ }