@maptiler/geocoding-control 2.1.0-with-autocomplete-timeout → 2.1.2

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 (50) hide show
  1. package/MapLibreBasedGeocodingControl.d.ts +35 -69
  2. package/leaflet-controller.js +1942 -1523
  3. package/leaflet-controller.js.map +1 -1
  4. package/leaflet-controller.umd.js +1 -22
  5. package/leaflet-controller.umd.js.map +1 -1
  6. package/leaflet.js +2798 -2385
  7. package/leaflet.js.map +1 -1
  8. package/leaflet.umd.js +1 -22
  9. package/leaflet.umd.js.map +1 -1
  10. package/maplibregl-controller.js +1918 -1498
  11. package/maplibregl-controller.js.map +1 -1
  12. package/maplibregl-controller.umd.js +1 -22
  13. package/maplibregl-controller.umd.js.map +1 -1
  14. package/maplibregl.d.ts +34 -68
  15. package/maplibregl.js +2892 -2478
  16. package/maplibregl.js.map +1 -1
  17. package/maplibregl.umd.js +1 -22
  18. package/maplibregl.umd.js.map +1 -1
  19. package/maptilersdk.d.ts +34 -68
  20. package/maptilersdk.js +2896 -2481
  21. package/maptilersdk.js.map +1 -1
  22. package/maptilersdk.umd.js +1 -22
  23. package/maptilersdk.umd.js.map +1 -1
  24. package/openlayers-controller.js +1686 -1264
  25. package/openlayers-controller.js.map +1 -1
  26. package/openlayers-controller.umd.js +1 -22
  27. package/openlayers-controller.umd.js.map +1 -1
  28. package/openlayers.js +2778 -2365
  29. package/openlayers.js.map +1 -1
  30. package/openlayers.umd.js +1 -22
  31. package/openlayers.umd.js.map +1 -1
  32. package/package.json +23 -23
  33. package/react.js +753 -756
  34. package/react.js.map +1 -1
  35. package/react.umd.js +1 -1
  36. package/react.umd.js.map +1 -1
  37. package/svelte/GeocodingControl.svelte +71 -58
  38. package/svelte/GeocodingControl.svelte.d.ts +5 -3
  39. package/svelte/MapLibreBasedGeocodingControl.d.ts +35 -69
  40. package/svelte/info.json +1 -0
  41. package/svelte/maplibregl.d.ts +34 -68
  42. package/svelte/maptilersdk.d.ts +34 -68
  43. package/svelte/maptilersdk.js +2 -0
  44. package/svelte/react.js +3 -0
  45. package/svelte/types.d.ts +175 -128
  46. package/types.d.ts +175 -128
  47. package/vanilla.js +847 -853
  48. package/vanilla.js.map +1 -1
  49. package/vanilla.umd.js +1 -1
  50. package/vanilla.umd.js.map +1 -1
package/types.d.ts CHANGED
@@ -62,247 +62,289 @@ export type ProximityRule = {
62
62
  } & PositionOptions));
63
63
  export type ControlOptions = {
64
64
  /**
65
- * Maptiler API key
65
+ * Callback function to adjust URL search parameters.
66
+ *
67
+ * Default: Empty function.
68
+ *
69
+ * @deprecated Use `adjustUrl` instead.
66
70
  */
67
- apiKey: string;
71
+ adjustUrlQuery?: (sp: URLSearchParams) => void;
68
72
  /**
69
- * Sets the amount of time, in milliseconds, to wait before querying the server when a user types into the Geocoder input box.
70
- * This parameter may be useful for reducing the total number of API calls made for a single query.
73
+ * Callback function to adjust the geocoding URL before fetching.
74
+ *
75
+ * @param url [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL) parameter that can be modified.
71
76
  *
72
- * Default value is `200`.
77
+ * Default: Empty function.
73
78
  */
74
- debounceSearch?: number;
79
+ adjustUrl?: (url: URL) => void;
75
80
  /**
76
- * Search results closer to the proximity point will be given higher priority. First matching rule from the array will be used.
77
- * Set to `null` to disable the proximity.
78
- *
79
- * Default value is `[{ type: "server-geolocation" }]`.
81
+ * MapTiler API key.
80
82
  */
81
- proximity?: ProximityRule[] | null;
83
+ apiKey: string;
82
84
  /**
83
- * Override the default placeholder attribute value.
85
+ * Geocoding API URL.
84
86
  *
85
- * Default value is `"Search"`.
87
+ * Default: MapTiler Geocoding API URL.
86
88
  */
87
- placeholder?: string;
89
+ apiUrl?: string;
88
90
  /**
89
- * Override the default error message.
91
+ * Bounding box in the format `[minX, minY, maxX, maxY]` to limit search results.
90
92
  *
91
- * Default value is `"Something went wrong…"`.
93
+ * Default: `undefined`.
92
94
  */
93
- errorMessage?: string;
95
+ bbox?: BBox;
94
96
  /**
95
- * Override the default message if no results are found.
97
+ * CSS class for the root element.
96
98
  *
97
- * Default value is `"Oops! Looks like you're trying to predict something that's not quite right. We can't seem to find what you're looking for. Maybe try double-checking your spelling or try a different search term. Keep on typing - we'll do our best to get you where you need to go!"`.
99
+ * Default: `undefined`.
98
100
  */
99
- noResultsMessage?: string;
101
+ class?: string;
100
102
  /**
101
- * Minimum number of characters to enter before results are shown.
103
+ * Title of the clear button.
102
104
  *
103
- * Default value is `2`.
105
+ * Default: `"clear"`.
104
106
  */
105
- minLength?: number;
107
+ clearButtonTitle?: string;
106
108
  /**
107
- * A bounding box argument: this is a bounding box given as an array in the format [minX, minY, maxX, maxY].
108
- * Search results will be limited to the bounding box.
109
+ * Clears the result list after picking an item.
110
+ * Prevents redisplaying the list when the input box is focused.
109
111
  *
110
- * Default value is `undefined`.
112
+ * Default: `false`.
111
113
  */
112
- bbox?: BBox;
114
+ clearListOnPick?: boolean;
113
115
  /**
114
- * Maximum number of results to show.
116
+ * Clears the input value when it loses focus.
115
117
  *
116
- * Default value is `5`.
118
+ * Default: `false`.
117
119
  */
118
- limit?: number;
120
+ clearOnBlur?: boolean;
119
121
  /**
120
- * Specify the language to use for response text and query result weighting.
121
- * Options are IETF language tags comprised of a mandatory ISO 639-1 language code and optionally one or more IETF subtags for country or script.
122
- * More than one value can also be specified, separated by commas.
123
- * Set to `null` or empty string for disabling language-specific searching.
122
+ * Collapses the geocoder control until hovered or focused.
124
123
  *
125
- * Default value is `undefined` which means to use the browser's language settings.
124
+ * Default: `false`.
126
125
  */
127
- language?: string | string[] | null;
126
+ collapsed?: boolean;
128
127
  /**
129
- * If `false`, indicates that search will only occur on enter key press.
130
- * If `true`, indicates that the Geocoder will search on the input box being updated above the minLength option.
128
+ * Limits search to the specified country or countries.
131
129
  *
132
- * Default value is `false`.
130
+ * Default: `undefined` (all countries).
133
131
  */
134
- showResultsWhileTyping?: boolean;
135
- autocompleteTimeout?: number;
132
+ country?: string | string[];
136
133
  /**
137
- * Set to `false` to disable fuzzy search.
134
+ * Time delay (in milliseconds) before querying the server after typing in the input box.
135
+ * Useful for reducing the number of API calls.
138
136
  *
139
- * Default value is `true`.
137
+ * Default: `200`.
140
138
  */
141
- fuzzyMatch?: boolean;
139
+ debounceSearch?: number;
142
140
  /**
143
- * On geocoded result what zoom level should the map animate to when a bbox in the response isn't present or is a point.
144
- * If a bbox is present and not a point then the map will fit to the bbox.
141
+ * Enables reverse geocoding:
142
+ * - `"button"`: Enables reverse geocoding button.
143
+ * - `"always"`: Reverse geocoding is always active.
145
144
  *
146
- * Value is key-value pairs, where key is a <type> or <type>.<categoy> and the value is the zoom level.
147
- *
148
- * Default value is `GeocodingControl.ZOOM_DEFAULTS`.
145
+ * Default: `"never"`.
149
146
  */
150
- zoom?: Record<string, number>;
147
+ enableReverse?: EnableReverse;
151
148
  /**
152
- * If `true`, the geocoder control will collapse until hovered or in focus.
149
+ * Custom error message.
153
150
  *
154
- * Default value is `false`.
151
+ * Default: `"Something went wrong…"`.
155
152
  */
156
- collapsed?: boolean;
153
+ errorMessage?: string;
157
154
  /**
158
- * If `true`, the geocoder control will clear its value when the input blurs.
155
+ * Includes all available types except those listed in the `types` option.
156
+ *
157
+ * See `reverseGeocodingExcludeTypes` for reverse geocoding exclusion.
159
158
  *
160
- * Default value is `false`.
159
+ * Default: `false`.
161
160
  */
162
- clearOnBlur?: boolean;
161
+ excludeTypes?: boolean;
163
162
  /**
164
- * 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.
163
+ * Uses the `limit` option value for reverse geocoding even if the `types` option has multiple elements.
164
+ * Works only if enabled on the server.
165
165
  *
166
- * Default value is `false`.
166
+ * Default: `false`.
167
167
  */
168
- clearListOnPick?: boolean;
168
+ exhaustiveReverseGeocoding?: boolean;
169
169
  /**
170
- * Keep the list open even if the control is not focused.
170
+ * Additional parameters for fetch requests.
171
171
  *
172
- * Default value is `false`.
172
+ * Default: `undefined`.
173
173
  */
174
- keepListOpen?: boolean;
174
+ fetchParameters?: RequestInit;
175
175
  /**
176
- * 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.
177
- * Return true to keep the item, false otherwise.
176
+ * Callback function to filter results from the Geocoding API response.
177
+ * The function should return `true` to keep an item, or `false` to exclude it.
178
178
  *
179
- * Default value is a function returning always `true`.
179
+ * Default: A function that always returns `true`.
180
180
  */
181
181
  filter?: (feature: Feature) => boolean;
182
182
  /**
183
- * Class of the root element.
183
+ * Animates the map to the selected feature from the result list.
184
184
  *
185
- * Default value is `undefined`.
185
+ * Default: `false`.
186
186
  */
187
- class?: string;
187
+ flyToSelected?: boolean;
188
188
  /**
189
- * Set to `button` to enable reverse geocoding button with title. Set to `"always"` to reverse geocoding be always active.
189
+ * Enables fuzzy search.
190
190
  *
191
- * Default value is `"never"`.
191
+ * Default: `true`.
192
192
  */
193
- enableReverse?: EnableReverse;
193
+ fuzzyMatch?: boolean;
194
194
  /**
195
- * Reverse mode active.
195
+ * Base URL for POI icons.
196
196
  *
197
- * Default value is `false`.
197
+ * Default:
198
+ * - `"icons/"` for Svelte apps.
199
+ * - `"https://cdn.maptiler.com/maptiler-geocoding-control/v${version}/icons/"` for others.
198
200
  */
199
- reverseActive?: boolean;
201
+ iconsBaseUrl?: string;
200
202
  /**
201
- * Title of the reverse toggle button.
203
+ * Keeps the result list open even if the control is unfocused.
202
204
  *
203
- * Default value is `"toggle reverse geocoding"`.
205
+ * Default: `false`.
204
206
  */
205
- reverseButtonTitle?: string;
207
+ keepListOpen?: boolean;
206
208
  /**
207
- * Title of the clear button.
209
+ * Language for response text and query weighting.
210
+ * Accepts IETF language tags.
211
+ * Set to `null` or an empty string to disable language-specific searching.
208
212
  *
209
- * Default value is `"clear"`.
213
+ * Default: `undefined` (uses the browser's language settings).
210
214
  */
211
- clearButtonTitle?: string;
215
+ language?: string | string[] | null;
212
216
  /**
213
- * Set to `"never"` to hide place/POI type. If set to `"always"` then type is shown for all items.
214
- * If set to `"if-needed"` then type is shown only for places/POIs not determined from the icon.
217
+ * Maximum number of results to display.
218
+ *
219
+ * See `reverseGeocodingLimit` for reverse geocoding limits.
215
220
  *
216
- * Default value is `"if-needed"`.
221
+ * Default: `5`.
217
222
  */
218
- showPlaceType?: ShowPlaceType;
223
+ limit?: number;
219
224
  /**
220
- * Style of the picked result on the map:
225
+ * Displays a marker on the selected feature from the result list.
221
226
  *
222
- * - `"marker-only"` - show only marker at the center of the feature
223
- * - `"full-geometry"` - show full feature geometry of the chosen result
224
- * - `"full-geometry-including-polygon-center-marker"` - show full feature geometry of the chosen result together with a marker in the center of polygon feature
227
+ * Default: `true`.
228
+ */
229
+ markerOnSelected?: boolean;
230
+ /**
231
+ * Minimum number of characters required to start a search.
225
232
  *
226
- * Default value is `true`.
233
+ * Default: `2`.
227
234
  */
228
- pickedResultStyle?: PickedResultStyle;
235
+ minLength?: number;
229
236
  /**
230
- * Limit search to specified country(ies).
237
+ * Custom message for when no results are found.
231
238
  *
232
- * Default value is `undefined` - use all countries.
239
+ * Default:
240
+ * ```
241
+ * "Oops! Looks like you're trying to predict something that's not quite right.
242
+ * We can't seem to find what you're looking for. Maybe try double-checking your spelling or try a different search term.
243
+ * Keep on typing - we'll do our best to get you where you need to go!"
244
+ * ```
233
245
  */
234
- country?: string | string[];
246
+ noResultsMessage?: string;
235
247
  /**
236
- * Filter of feature types to return.
248
+ * Style of the picked result on the map:
249
+ * - `"marker-only"`: Show only a marker at the center of the feature.
250
+ * - `"full-geometry"`: Display the full feature geometry.
251
+ * - `"full-geometry-including-polygon-center-marker"`: Display full geometry with a marker at the polygon center.
237
252
  *
238
- * Default value is `undefined` - all available feature types are returned.
253
+ * Default: `"full-geometry"`.
239
254
  */
240
- types?: string[];
255
+ pickedResultStyle?: PickedResultStyle;
241
256
  /**
242
- * Use `limit` value for reverse geocoding even if `types` is not an array with a single element.
243
- * Will work only if enabled on the server.
257
+ * Custom placeholder for the input box.
244
258
  *
245
- * Default value is `false`.
259
+ * Default: `"Search"`.
246
260
  */
247
- exhaustiveReverseGeocoding?: boolean;
261
+ placeholder?: string;
248
262
  /**
249
- * If set to `true` then use all types except for those listed in `types`.
263
+ * Prioritizes search results closer to a proximity point.
264
+ * The first matching rule in the array is used.
265
+ * Set to `null` to disable proximity.
250
266
  *
251
- * Default value is `false`.
267
+ * Default: `[ { type: "server-geolocation" } ]`.
252
268
  */
253
- excludeTypes?: boolean;
269
+ proximity?: ProximityRule[] | null;
254
270
  /**
255
- * Geocoding API URL.
271
+ * Activates reverse geocoding.
256
272
  *
257
- * Default value is MapTiler Geocoding API URL.
273
+ * Default: `false`.
258
274
  */
259
- apiUrl?: string;
275
+ reverseActive?: boolean;
260
276
  /**
261
- * Extra fetch parameters.
277
+ * Title of the reverse geocoding toggle button.
262
278
  *
263
- * Default value is `undefined`.
279
+ * Default: `"toggle reverse geocoding"`.
264
280
  */
265
- fetchParameters?: RequestInit;
281
+ reverseButtonTitle?: string;
266
282
  /**
267
- * Base URL for POI icons.
283
+ * Excludes types for reverse geocoding.
268
284
  *
269
- * Default value is `"icons/"` for Svelte apps, otherwise `"https://cdn.maptiler.com/maptiler-geocoding-control/v${version}/icons/"`.
285
+ * Default: Same as `excludeTypes`.
270
286
  */
271
- iconsBaseUrl?: string;
287
+ reverseGeocodingExcludeTypes?: boolean;
272
288
  /**
273
- * Function to adjust URL search parameters.
289
+ * Limits results for reverse geocoding.
290
+ * Applied only if value is 1 or effective types contain a single value.
274
291
  *
275
- * Default value is empty function.
292
+ * See also `reverseGeocodingTypes` option.
276
293
  *
277
- * @deprecated use `adjustUrl`
294
+ * Default: The value of the `limit` option if set. If effective types contain a single value, the default is `1`. In all other cases, this option is not used.
278
295
  */
279
- adjustUrlQuery?: (sp: URLSearchParams) => void;
296
+ reverseGeocodingLimit?: number;
280
297
  /**
281
- * Function to adjust geocoding URL before the fetch.
298
+ * Specifies types for reverse geocoding.
299
+ *
300
+ * If effective types are multiple values, the `limit`/`reverseGeocodingLimit` option is ignored.
282
301
  *
283
- * @param url [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL) parameter which can be modified
302
+ * See also `reverseGeocodingLimit` option.
284
303
  *
285
- * Default value is empty function.
304
+ * Default: Same as `types`.
286
305
  */
287
- adjustUrl?: (url: URL) => void;
306
+ reverseGeocodingTypes?: TypeRule[];
288
307
  /**
289
- * Automatically select the first feature from the result list.
308
+ * Automatically selects the first feature in the result list.
290
309
  *
291
- * Default value is `true`.
310
+ * Default: `true`.
292
311
  */
293
312
  selectFirst?: boolean;
294
313
  /**
295
- * Fly to selected feature from the result list.
314
+ * Indicates when to show place/POI types in the dropdown:
315
+ * - `"never"`: Hide the type.
316
+ * - `"always"`: Always show the type.
317
+ * - `"if-needed"`: Show the type only if it cannot be determined from the icon.
296
318
  *
297
- * Default value is `false`.
319
+ * Default: `"if-needed"`.
298
320
  */
299
- flyToSelected?: boolean;
321
+ showPlaceType?: ShowPlaceType;
300
322
  /**
301
- * Show marker on the selected feature from the result list.
323
+ * Displays results while typing:
324
+ * - `false`: Search occurs only on pressing the Enter key.
325
+ * - `true`: Search begins when the input meets the `minLength` requirement.
302
326
  *
303
- * Default value is `true`.
327
+ * Default: `false`.
304
328
  */
305
- markerOnSelected?: boolean;
329
+ showResultsWhileTyping?: boolean;
330
+ /**
331
+ * Types to query, either as an array or `[minZoom, maxZoom, type]` format.
332
+ * `minZoom` is inclusive, `maxZoom` is exclusive, and either can be `null` or `undefined` for unbounded values.
333
+ *
334
+ * See `reverseGeocodingTypes` option for reverse geocoding types.
335
+ *
336
+ * Default: `undefined` (uses server default feature types).
337
+ */
338
+ types?: TypeRule[];
339
+ /**
340
+ * Specifies the zoom level to animate the map to for a geocoded result when no bounding box is present or when the result is a point.
341
+ * If a bounding box is present and not a point, the map will fit to the bounding box.
342
+ *
343
+ * Values are key-value pairs where the key is a `<type>` or `<type>.<category>` and the value is the zoom level.
344
+ *
345
+ * Default: `GeocodingControl.ZOOM_DEFAULTS`.
346
+ */
347
+ zoom?: Record<string, number>;
306
348
  };
307
349
  export type PickedResultStyle = "marker-only" | "full-geometry" | "full-geometry-including-polygon-center-marker";
308
350
  export type EnableReverse = "never" | "always" | "button";
@@ -342,3 +384,8 @@ export type RedefineType<OriginalType, UpdatedType extends {
342
384
  } & {
343
385
  [K in Exclude<keyof UpdatedType, keyof OriginalType>]: never;
344
386
  }> = UpdatedType;
387
+ export type TypeRule = string | [
388
+ minZoom: number | null | undefined,
389
+ maxZoom: number | null | undefined,
390
+ type: string
391
+ ];