@maptiler/geocoding-control 2.0.1 → 2.1.0-rc1

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 (110) hide show
  1. package/MapLibreBasedGeocodingControl.d.ts +1037 -626
  2. package/icons/10pin.svg +4 -1
  3. package/icons/9pin.svg +4 -1
  4. package/icons/alcohol.svg +1 -1
  5. package/icons/alpine_hut.svg +1 -1
  6. package/icons/apartment.svg +4 -1
  7. package/icons/area.svg +1 -5
  8. package/icons/artwork.svg +4 -1
  9. package/icons/beauty.svg +14 -1
  10. package/icons/bicycle_repair_station.svg +18 -1
  11. package/icons/biergarten.svg +4 -1
  12. package/icons/books.svg +14 -1
  13. package/icons/bowl.svg +4 -1
  14. package/icons/bowling_alley.svg +4 -1
  15. package/icons/bus_station.svg +1 -1
  16. package/icons/camping.svg +1 -1
  17. package/icons/car_repair.svg +14 -1
  18. package/icons/car_wash.svg +19 -1
  19. package/icons/cave_entrance.svg +15 -1
  20. package/icons/chalet.svg +1 -1
  21. package/icons/chemist.svg +14 -1
  22. package/icons/church.svg +4 -1
  23. package/icons/community_centre.svg +20 -1
  24. package/icons/firestation.svg +4 -1
  25. package/icons/guest_house.svg +29 -8
  26. package/icons/hotel.svg +1 -1
  27. package/icons/housenumber.svg +19 -14
  28. package/icons/hut.svg +1 -4
  29. package/icons/medical_supply.svg +20 -1
  30. package/icons/memorial.svg +14 -1
  31. package/icons/motel.svg +19 -1
  32. package/icons/post.svg +1 -1
  33. package/icons/post_office.svg +1 -1
  34. package/icons/postal_code.svg +1 -23
  35. package/icons/public_bookcase.svg +14 -1
  36. package/icons/public_building.svg +4 -1
  37. package/icons/shintoist.svg +1 -1
  38. package/icons/street.svg +11 -14
  39. package/icons/vehicle_inspection.svg +18 -1
  40. package/icons/wilderness_hut.svg +1 -1
  41. package/leaflet-controller.js +32 -31
  42. package/leaflet-controller.js.map +1 -1
  43. package/leaflet-controller.umd.js +1 -1
  44. package/leaflet-controller.umd.js.map +1 -1
  45. package/leaflet.d.ts +32 -1
  46. package/leaflet.js +1578 -1402
  47. package/leaflet.js.map +1 -1
  48. package/leaflet.umd.js +3 -3
  49. package/leaflet.umd.js.map +1 -1
  50. package/maplibregl-controller.js +5 -5
  51. package/maplibregl-controller.js.map +1 -1
  52. package/maplibregl-controller.umd.js +1 -1
  53. package/maplibregl-controller.umd.js.map +1 -1
  54. package/maplibregl.d.ts +527 -626
  55. package/maplibregl.js +1709 -1538
  56. package/maplibregl.js.map +1 -1
  57. package/maplibregl.umd.js +3 -3
  58. package/maplibregl.umd.js.map +1 -1
  59. package/maptilersdk.d.ts +527 -626
  60. package/maptilersdk.js +1705 -1534
  61. package/maptilersdk.js.map +1 -1
  62. package/maptilersdk.umd.js +3 -3
  63. package/maptilersdk.umd.js.map +1 -1
  64. package/openlayers-controller.js +5 -4
  65. package/openlayers-controller.js.map +1 -1
  66. package/openlayers-controller.umd.js +1 -1
  67. package/openlayers-controller.umd.js.map +1 -1
  68. package/openlayers.d.ts +32 -1
  69. package/openlayers.js +2009 -1833
  70. package/openlayers.js.map +1 -1
  71. package/openlayers.umd.js +3 -3
  72. package/openlayers.umd.js.map +1 -1
  73. package/package.json +23 -23
  74. package/react.d.ts +27 -1
  75. package/react.js +1284 -1128
  76. package/react.js.map +1 -1
  77. package/react.umd.js +1 -1
  78. package/react.umd.js.map +1 -1
  79. package/style.css +1 -1
  80. package/svelte/FeatureItem.svelte +59 -12
  81. package/svelte/FeatureItem.svelte.d.ts +2 -2
  82. package/svelte/GeocodingControl.svelte +140 -71
  83. package/svelte/GeocodingControl.svelte.d.ts +10 -3
  84. package/svelte/MapLibreBasedGeocodingControl.d.ts +1037 -626
  85. package/svelte/MapLibreBasedGeocodingControl.js +36 -6
  86. package/svelte/leaflet-controller.js +3 -3
  87. package/svelte/leaflet.d.ts +32 -1
  88. package/svelte/leaflet.js +35 -2
  89. package/svelte/maplibregl-controller.js +3 -3
  90. package/svelte/maplibregl.d.ts +527 -626
  91. package/svelte/maptilersdk.d.ts +527 -626
  92. package/svelte/openlayers-controller.js +4 -4
  93. package/svelte/openlayers.d.ts +32 -1
  94. package/svelte/openlayers.js +36 -3
  95. package/svelte/react.d.ts +27 -1
  96. package/svelte/react.js +16 -4
  97. package/svelte/types.d.ts +23 -1
  98. package/svelte/vanilla.d.ts +32 -1
  99. package/svelte/vanilla.js +35 -2
  100. package/types.d.ts +23 -1
  101. package/vanilla.d.ts +32 -1
  102. package/vanilla.js +1153 -978
  103. package/vanilla.js.map +1 -1
  104. package/vanilla.umd.js +1 -1
  105. package/vanilla.umd.js.map +1 -1
  106. package/icons/aerodrome.12.svg +0 -1
  107. package/icons/bus_stop.12.svg +0 -1
  108. package/icons/elevator.12.svg +0 -1
  109. /package/icons/{helipad.16.svg → helipad.svg} +0 -0
  110. /package/icons/{traffic_light.13.svg → traffic_light.svg} +0 -0
@@ -191,7 +191,7 @@ export function createOpenLayersMapController(map, flyToOptions = {}, flyToBound
191
191
  if (reverseMarker) {
192
192
  source.addFeature(reverseMarker);
193
193
  }
194
- if (picked) {
194
+ block: if (picked) {
195
195
  let handled = false;
196
196
  if (picked.geometry.type === "GeometryCollection") {
197
197
  const geoms = picked.geometry.geometries
@@ -229,14 +229,14 @@ export function createOpenLayersMapController(map, flyToOptions = {}, flyToBound
229
229
  }
230
230
  else if (picked.geometry.type === "LineString") {
231
231
  source.addFeature(new OlFeature(fromWgs84(new OlLineString(picked.geometry.coordinates))));
232
- return; // no pin for (multi)linestrings
232
+ break block; // no pin for (multi)linestrings
233
233
  }
234
234
  else if (picked.geometry.type === "MultiLineString") {
235
235
  source.addFeature(new OlFeature(fromWgs84(new OlMultiLineString(picked.geometry.coordinates))));
236
- return; // no pin for (multi)linestrings
236
+ break block; // no pin for (multi)linestrings
237
237
  }
238
238
  if (!showPolygonMarker && picked.geometry.type !== "Point") {
239
- return;
239
+ break block;
240
240
  }
241
241
  source.addFeature(new OlFeature(fromWgs84(new OlPoint(picked.center))));
242
242
  }
@@ -36,11 +36,42 @@ export declare class GeocodingControl extends Control {
36
36
  un: CustomObjectOnSignature<EventsKey>;
37
37
  constructor(options: OpenLayersControlOptions);
38
38
  setMap(map: Map | null): void;
39
+ /**
40
+ * Update the control options.
41
+ *
42
+ * @param options options to update
43
+ */
39
44
  setOptions(options: OpenLayersControlOptions): void;
45
+ /**
46
+ * Set the content of search input box.
47
+ *
48
+ * @param value text to set
49
+ * @param submit perform the search
50
+ */
40
51
  setQuery(value: string, submit?: boolean): void;
52
+ /**
53
+ * Clear geocoding search results from the map.
54
+ */
41
55
  clearMap(): void;
56
+ /**
57
+ * Clear search result list.
58
+ */
42
59
  clearList(): void;
43
- focus(): void;
60
+ /**
61
+ * Set reverse geocoding mode.
62
+ *
63
+ * @param reverseActive reverse geocoding active
64
+ */
65
+ setReverseMode(reverseActive: boolean): void;
66
+ /**
67
+ * Focus the search input box.
68
+ *
69
+ * @param options [FocusOptions](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus#options)
70
+ */
71
+ focus(options?: FocusOptions): void;
72
+ /**
73
+ * Blur the search input box.
74
+ */
44
75
  blur(): void;
45
76
  }
46
77
  export declare class SelectEvent extends BaseEvent {
@@ -61,6 +61,11 @@ export class GeocodingControl extends Control {
61
61
  this.#gc?.$set({ mapController });
62
62
  }
63
63
  }
64
+ /**
65
+ * Update the control options.
66
+ *
67
+ * @param options options to update
68
+ */
64
69
  setOptions(options) {
65
70
  Object.assign(this.#options, options);
66
71
  const { flyTo, fullGeometryStyle, ...restOptions } = this.#options;
@@ -69,18 +74,46 @@ export class GeocodingControl extends Control {
69
74
  flyTo: flyTo === undefined ? true : !!flyTo,
70
75
  });
71
76
  }
77
+ /**
78
+ * Set the content of search input box.
79
+ *
80
+ * @param value text to set
81
+ * @param submit perform the search
82
+ */
72
83
  setQuery(value, submit = true) {
73
84
  this.#gc?.setQuery(value, submit);
74
85
  }
86
+ /**
87
+ * Clear geocoding search results from the map.
88
+ */
75
89
  clearMap() {
76
90
  this.#gc?.clearMap();
77
91
  }
92
+ /**
93
+ * Clear search result list.
94
+ */
78
95
  clearList() {
79
96
  this.#gc?.clearList();
80
97
  }
81
- focus() {
82
- this.#gc?.focus();
83
- }
98
+ /**
99
+ * Set reverse geocoding mode.
100
+ *
101
+ * @param reverseActive reverse geocoding active
102
+ */
103
+ setReverseMode(reverseActive) {
104
+ this.#gc?.$set({ reverseActive });
105
+ }
106
+ /**
107
+ * Focus the search input box.
108
+ *
109
+ * @param options [FocusOptions](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus#options)
110
+ */
111
+ focus(options) {
112
+ this.#gc?.focus(options);
113
+ }
114
+ /**
115
+ * Blur the search input box.
116
+ */
84
117
  blur() {
85
118
  this.#gc?.blur();
86
119
  }
package/svelte/react.d.ts CHANGED
@@ -9,11 +9,37 @@ type MapControllerProp = {
9
9
  };
10
10
  export type Props = ControlOptions & CallbackProperties<DispatcherTypeCC> & MapControllerProp;
11
11
  export type Methods = {
12
+ /**
13
+ * Blur the search input box.
14
+ */
12
15
  blur(): void;
13
- focus(): void;
16
+ /**
17
+ * Focus the search input box.
18
+ *
19
+ * @param options [FocusOptions](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus#options)
20
+ */
21
+ focus(options?: FocusOptions): void;
22
+ /**
23
+ * Set the content of search input box.
24
+ *
25
+ * @param value text to set
26
+ * @param submit perform the search
27
+ */
14
28
  setQuery(value: string, submit?: boolean): void;
29
+ /**
30
+ * Clear geocoding search results from the map.
31
+ */
15
32
  clearMap(): void;
33
+ /**
34
+ * Clear search result list.
35
+ */
16
36
  clearList(): void;
37
+ /**
38
+ * Set reverse geocoding mode.
39
+ *
40
+ * @param reverseActive reverse geocoding active
41
+ */
42
+ setReverseMode(reverseActive: boolean): void;
17
43
  };
18
44
  declare const ReactGeocodingControl: import("react").ForwardRefExoticComponent<ControlOptions & CallbackProperties<DispatcherTypeCC> & MapControllerProp & import("react").RefAttributes<Methods>>;
19
45
  export { ReactGeocodingControl as GeocodingControl };
package/svelte/react.js CHANGED
@@ -12,9 +12,13 @@ const eventNames = [
12
12
  ];
13
13
  const propertyNames = [
14
14
  "adjustUrlQuery",
15
+ "adjustUrl",
15
16
  "apiKey",
17
+ "apiUrl",
16
18
  "bbox",
19
+ "class",
17
20
  "clearButtonTitle",
21
+ "clearListOnPick",
18
22
  "clearOnBlur",
19
23
  "collapsed",
20
24
  "country",
@@ -22,11 +26,17 @@ const propertyNames = [
22
26
  "enableReverse",
23
27
  "errorMessage",
24
28
  "excludeTypes",
29
+ "exhaustiveReverseGeocoding",
30
+ "fetchParameters",
25
31
  "filter",
32
+ "flyToSelected",
26
33
  "fuzzyMatch",
34
+ "iconsBaseUrl",
35
+ "keepListOpen",
27
36
  "language",
28
37
  "limit",
29
38
  "mapController",
39
+ "markerOnSelected",
30
40
  "minLength",
31
41
  "noResultsMessage",
32
42
  "pickedResultStyle",
@@ -34,6 +44,7 @@ const propertyNames = [
34
44
  "proximity",
35
45
  "reverseActive",
36
46
  "reverseButtonTitle",
47
+ "selectFirst",
37
48
  "showPlaceType",
38
49
  "showResultsWhileTyping",
39
50
  "types",
@@ -45,8 +56,8 @@ function getEventFnName(name) {
45
56
  name.slice(1));
46
57
  }
47
58
  const ReactGeocodingControl = forwardRef(function ReactGeocodingControl(props, ref) {
48
- const divRef = useRef();
49
- const controlRef = useRef();
59
+ const divRef = useRef(undefined);
60
+ const controlRef = useRef(undefined);
50
61
  const options = { ...props };
51
62
  for (const eventName of eventNames) {
52
63
  // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
@@ -75,7 +86,7 @@ const ReactGeocodingControl = forwardRef(function ReactGeocodingControl(props, r
75
86
  for (const eventName of eventNames) {
76
87
  const eventHandlerFn = props[getEventFnName(eventName)];
77
88
  useEffect(() => eventHandlerFn &&
78
- controlRef.current?.$on(eventName, (e) => {
89
+ controlRef.current?.$on(eventName.toLowerCase(), (e) => {
79
90
  eventHandlerFn(e.detail);
80
91
  }), [eventHandlerFn]);
81
92
  }
@@ -83,8 +94,9 @@ const ReactGeocodingControl = forwardRef(function ReactGeocodingControl(props, r
83
94
  setQuery: (value, submit = true) => controlRef.current?.setQuery(value, submit),
84
95
  clearMap: () => controlRef.current?.clearMap(),
85
96
  clearList: () => controlRef.current?.clearList(),
86
- focus: () => controlRef.current?.focus(),
97
+ focus: (options) => controlRef.current?.focus(options),
87
98
  blur: () => controlRef.current?.blur(),
99
+ setReverseMode: (reverseActive) => controlRef.current?.$set({ reverseActive }),
88
100
  }));
89
101
  return createElement("div", { ref: divRef });
90
102
  });
package/svelte/types.d.ts CHANGED
@@ -154,11 +154,23 @@ export type ControlOptions = {
154
154
  */
155
155
  collapsed?: boolean;
156
156
  /**
157
- * If true, the geocoder control will clear its value when the input blurs.
157
+ * If `true`, the geocoder control will clear its value when the input blurs.
158
158
  *
159
159
  * Default value is `false`.
160
160
  */
161
161
  clearOnBlur?: boolean;
162
+ /**
163
+ * If `true`, then after picking a result from the list or map the list will be cleared and not re-displayed on input box focus.
164
+ *
165
+ * Default value is `false`.
166
+ */
167
+ clearListOnPick?: boolean;
168
+ /**
169
+ * Keep the list open even if the control is not focused.
170
+ *
171
+ * Default value is `false`.
172
+ */
173
+ keepListOpen?: boolean;
162
174
  /**
163
175
  * A function which accepts a Feature in the Carmen GeoJSON format to filter out results from the Geocoding API response before they are included in the suggestions list.
164
176
  * Return true to keep the item, false otherwise.
@@ -260,8 +272,18 @@ export type ControlOptions = {
260
272
  * Function to adjust URL search parameters.
261
273
  *
262
274
  * Default value is empty function.
275
+ *
276
+ * @deprecated use `adjustUrl`
263
277
  */
264
278
  adjustUrlQuery?: (sp: URLSearchParams) => void;
279
+ /**
280
+ * Function to adjust geocoding URL before the fetch.
281
+ *
282
+ * @param url [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL) parameter which can be modified
283
+ *
284
+ * Default value is empty function.
285
+ */
286
+ adjustUrl?: (url: URL) => void;
265
287
  /**
266
288
  * Automatically select the first feature from the result list.
267
289
  *
@@ -17,11 +17,42 @@ export declare class GeocodingControl extends EventTarget {
17
17
  constructor({ target, ...options }: Options & {
18
18
  target: HTMLElement;
19
19
  });
20
+ /**
21
+ * Update the control options.
22
+ *
23
+ * @param options options to update
24
+ */
20
25
  setOptions(options: Partial<Options>): void;
26
+ /**
27
+ * Set the content of search input box.
28
+ *
29
+ * @param value text to set
30
+ * @param submit perform the search
31
+ */
21
32
  setQuery(value: string, submit?: boolean): void;
33
+ /**
34
+ * Clear geocoding search results from the map.
35
+ */
22
36
  clearMap(): void;
37
+ /**
38
+ * Clear search result list.
39
+ */
23
40
  clearList(): void;
24
- focus(): void;
41
+ /**
42
+ * Set reverse geocoding mode.
43
+ *
44
+ * @param reverseActive reverse geocoding active
45
+ */
46
+ setReverseMode(reverseActive: boolean): void;
47
+ /**
48
+ * Focus the search input box.
49
+ *
50
+ * @param options [FocusOptions](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus#options)
51
+ */
52
+ focus(options?: FocusOptions): void;
53
+ /**
54
+ * Blur the search input box.
55
+ */
25
56
  blur(): void;
26
57
  addEventListener<K extends keyof CustomEventMap>(type: K, callback: CustomEventListenerOrEventListenerObject<K> | null, options?: AddEventListenerOptions | boolean): void;
27
58
  removeEventListener<K extends keyof CustomEventMap>(type: K, callback: CustomEventListenerOrEventListenerObject<K> | null, options?: EventListenerOptions | boolean): void;
package/svelte/vanilla.js CHANGED
@@ -33,21 +33,54 @@ export class GeocodingControl extends EventTarget {
33
33
  });
34
34
  finalizationRegistry.register(this, this.#gc);
35
35
  }
36
+ /**
37
+ * Update the control options.
38
+ *
39
+ * @param options options to update
40
+ */
36
41
  setOptions(options) {
37
42
  this.#gc.$set(options);
38
43
  }
44
+ /**
45
+ * Set the content of search input box.
46
+ *
47
+ * @param value text to set
48
+ * @param submit perform the search
49
+ */
39
50
  setQuery(value, submit = true) {
40
51
  this.#gc?.setQuery(value, submit);
41
52
  }
53
+ /**
54
+ * Clear geocoding search results from the map.
55
+ */
42
56
  clearMap() {
43
57
  this.#gc?.clearMap();
44
58
  }
59
+ /**
60
+ * Clear search result list.
61
+ */
45
62
  clearList() {
46
63
  this.#gc?.clearList();
47
64
  }
48
- focus() {
49
- this.#gc?.focus();
65
+ /**
66
+ * Set reverse geocoding mode.
67
+ *
68
+ * @param reverseActive reverse geocoding active
69
+ */
70
+ setReverseMode(reverseActive) {
71
+ this.#gc?.$set({ reverseActive });
50
72
  }
73
+ /**
74
+ * Focus the search input box.
75
+ *
76
+ * @param options [FocusOptions](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus#options)
77
+ */
78
+ focus(options) {
79
+ this.#gc?.focus(options);
80
+ }
81
+ /**
82
+ * Blur the search input box.
83
+ */
51
84
  blur() {
52
85
  this.#gc?.blur();
53
86
  }
package/types.d.ts CHANGED
@@ -154,11 +154,23 @@ export type ControlOptions = {
154
154
  */
155
155
  collapsed?: boolean;
156
156
  /**
157
- * If true, the geocoder control will clear its value when the input blurs.
157
+ * If `true`, the geocoder control will clear its value when the input blurs.
158
158
  *
159
159
  * Default value is `false`.
160
160
  */
161
161
  clearOnBlur?: boolean;
162
+ /**
163
+ * If `true`, then after picking a result from the list or map the list will be cleared and not re-displayed on input box focus.
164
+ *
165
+ * Default value is `false`.
166
+ */
167
+ clearListOnPick?: boolean;
168
+ /**
169
+ * Keep the list open even if the control is not focused.
170
+ *
171
+ * Default value is `false`.
172
+ */
173
+ keepListOpen?: boolean;
162
174
  /**
163
175
  * A function which accepts a Feature in the Carmen GeoJSON format to filter out results from the Geocoding API response before they are included in the suggestions list.
164
176
  * Return true to keep the item, false otherwise.
@@ -260,8 +272,18 @@ export type ControlOptions = {
260
272
  * Function to adjust URL search parameters.
261
273
  *
262
274
  * Default value is empty function.
275
+ *
276
+ * @deprecated use `adjustUrl`
263
277
  */
264
278
  adjustUrlQuery?: (sp: URLSearchParams) => void;
279
+ /**
280
+ * Function to adjust geocoding URL before the fetch.
281
+ *
282
+ * @param url [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL) parameter which can be modified
283
+ *
284
+ * Default value is empty function.
285
+ */
286
+ adjustUrl?: (url: URL) => void;
265
287
  /**
266
288
  * Automatically select the first feature from the result list.
267
289
  *
package/vanilla.d.ts CHANGED
@@ -17,11 +17,42 @@ export declare class GeocodingControl extends EventTarget {
17
17
  constructor({ target, ...options }: Options & {
18
18
  target: HTMLElement;
19
19
  });
20
+ /**
21
+ * Update the control options.
22
+ *
23
+ * @param options options to update
24
+ */
20
25
  setOptions(options: Partial<Options>): void;
26
+ /**
27
+ * Set the content of search input box.
28
+ *
29
+ * @param value text to set
30
+ * @param submit perform the search
31
+ */
21
32
  setQuery(value: string, submit?: boolean): void;
33
+ /**
34
+ * Clear geocoding search results from the map.
35
+ */
22
36
  clearMap(): void;
37
+ /**
38
+ * Clear search result list.
39
+ */
23
40
  clearList(): void;
24
- focus(): void;
41
+ /**
42
+ * Set reverse geocoding mode.
43
+ *
44
+ * @param reverseActive reverse geocoding active
45
+ */
46
+ setReverseMode(reverseActive: boolean): void;
47
+ /**
48
+ * Focus the search input box.
49
+ *
50
+ * @param options [FocusOptions](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus#options)
51
+ */
52
+ focus(options?: FocusOptions): void;
53
+ /**
54
+ * Blur the search input box.
55
+ */
25
56
  blur(): void;
26
57
  addEventListener<K extends keyof CustomEventMap>(type: K, callback: CustomEventListenerOrEventListenerObject<K> | null, options?: AddEventListenerOptions | boolean): void;
27
58
  removeEventListener<K extends keyof CustomEventMap>(type: K, callback: CustomEventListenerOrEventListenerObject<K> | null, options?: EventListenerOptions | boolean): void;