@maptiler/geocoding-control 2.1.0-rc1 → 2.1.1

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 (61) hide show
  1. package/leaflet-controller.js +1942 -1523
  2. package/leaflet-controller.js.map +1 -1
  3. package/leaflet-controller.umd.js +1 -22
  4. package/leaflet-controller.umd.js.map +1 -1
  5. package/leaflet.js +2800 -2368
  6. package/leaflet.js.map +1 -1
  7. package/leaflet.umd.js +1 -22
  8. package/leaflet.umd.js.map +1 -1
  9. package/maplibregl-controller.js +1918 -1498
  10. package/maplibregl-controller.js.map +1 -1
  11. package/maplibregl-controller.umd.js +1 -22
  12. package/maplibregl-controller.umd.js.map +1 -1
  13. package/maplibregl.js +2858 -2425
  14. package/maplibregl.js.map +1 -1
  15. package/maplibregl.umd.js +1 -22
  16. package/maplibregl.umd.js.map +1 -1
  17. package/maptilersdk.js +2863 -2428
  18. package/maptilersdk.js.map +1 -1
  19. package/maptilersdk.umd.js +1 -22
  20. package/maptilersdk.umd.js.map +1 -1
  21. package/openlayers-controller.js +1686 -1264
  22. package/openlayers-controller.js.map +1 -1
  23. package/openlayers-controller.umd.js +1 -22
  24. package/openlayers-controller.umd.js.map +1 -1
  25. package/openlayers.js +2785 -2353
  26. package/openlayers.js.map +1 -1
  27. package/openlayers.umd.js +1 -22
  28. package/openlayers.umd.js.map +1 -1
  29. package/package.json +19 -19
  30. package/react.js +800 -784
  31. package/react.js.map +1 -1
  32. package/react.umd.js +1 -1
  33. package/react.umd.js.map +1 -1
  34. package/{MapLibreBasedGeocodingControl.d.ts → src/MapLibreBasedGeocodingControl.d.ts} +35 -69
  35. package/{maplibregl.d.ts → src/maplibregl.d.ts} +34 -68
  36. package/{maptilersdk.d.ts → src/maptilersdk.d.ts} +34 -68
  37. package/src/types.d.ts +391 -0
  38. package/svelte/GeocodingControl.svelte +55 -14
  39. package/svelte/GeocodingControl.svelte.d.ts +5 -2
  40. package/svelte/MapLibreBasedGeocodingControl.d.ts +35 -69
  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 -127
  46. package/vanilla.js +870 -857
  47. package/vanilla.js.map +1 -1
  48. package/vanilla.umd.js +1 -1
  49. package/vanilla.umd.js.map +1 -1
  50. package/types.d.ts +0 -343
  51. /package/{geo-coordinates-parser.t.d.ts → src/geo-coordinates-parser.t.d.ts} +0 -0
  52. /package/{geoUtils.d.ts → src/geoUtils.d.ts} +0 -0
  53. /package/{leaflet-controller.d.ts → src/leaflet-controller.d.ts} +0 -0
  54. /package/{leaflet.d.ts → src/leaflet.d.ts} +0 -0
  55. /package/{maplibregl-controller.d.ts → src/maplibregl-controller.d.ts} +0 -0
  56. /package/{mask.d.ts → src/mask.d.ts} +0 -0
  57. /package/{openlayers-controller.d.ts → src/openlayers-controller.d.ts} +0 -0
  58. /package/{openlayers.d.ts → src/openlayers.d.ts} +0 -0
  59. /package/{proximity.d.ts → src/proximity.d.ts} +0 -0
  60. /package/{react.d.ts → src/react.d.ts} +0 -0
  61. /package/{vanilla.d.ts → src/vanilla.d.ts} +0 -0
package/svelte/types.d.ts CHANGED
@@ -62,246 +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;
132
+ country?: string | string[];
135
133
  /**
136
- * 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.
137
136
  *
138
- * Default value is `true`.
137
+ * Default: `200`.
139
138
  */
140
- fuzzyMatch?: boolean;
139
+ debounceSearch?: number;
141
140
  /**
142
- * On geocoded result what zoom level should the map animate to when a bbox in the response isn't present or is a point.
143
- * 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.
144
144
  *
145
- * Value is key-value pairs, where key is a <type> or <type>.<categoy> and the value is the zoom level.
146
- *
147
- * Default value is `GeocodingControl.ZOOM_DEFAULTS`.
145
+ * Default: `"never"`.
148
146
  */
149
- zoom?: Record<string, number>;
147
+ enableReverse?: EnableReverse;
150
148
  /**
151
- * If `true`, the geocoder control will collapse until hovered or in focus.
149
+ * Custom error message.
152
150
  *
153
- * Default value is `false`.
151
+ * Default: `"Something went wrong…"`.
154
152
  */
155
- collapsed?: boolean;
153
+ errorMessage?: string;
156
154
  /**
157
- * 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.
158
158
  *
159
- * Default value is `false`.
159
+ * Default: `false`.
160
160
  */
161
- clearOnBlur?: boolean;
161
+ excludeTypes?: boolean;
162
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.
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.
164
165
  *
165
- * Default value is `false`.
166
+ * Default: `false`.
166
167
  */
167
- clearListOnPick?: boolean;
168
+ exhaustiveReverseGeocoding?: boolean;
168
169
  /**
169
- * Keep the list open even if the control is not focused.
170
+ * Additional parameters for fetch requests.
170
171
  *
171
- * Default value is `false`.
172
+ * Default: `undefined`.
172
173
  */
173
- keepListOpen?: boolean;
174
+ fetchParameters?: RequestInit;
174
175
  /**
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.
176
- * 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.
177
178
  *
178
- * Default value is a function returning always `true`.
179
+ * Default: A function that always returns `true`.
179
180
  */
180
181
  filter?: (feature: Feature) => boolean;
181
182
  /**
182
- * Class of the root element.
183
+ * Animates the map to the selected feature from the result list.
183
184
  *
184
- * Default value is `undefined`.
185
+ * Default: `false`.
185
186
  */
186
- class?: string;
187
+ flyToSelected?: boolean;
187
188
  /**
188
- * Set to `button` to enable reverse geocoding button with title. Set to `"always"` to reverse geocoding be always active.
189
+ * Enables fuzzy search.
189
190
  *
190
- * Default value is `"never"`.
191
+ * Default: `true`.
191
192
  */
192
- enableReverse?: EnableReverse;
193
+ fuzzyMatch?: boolean;
193
194
  /**
194
- * Reverse mode active.
195
+ * Base URL for POI icons.
195
196
  *
196
- * Default value is `false`.
197
+ * Default:
198
+ * - `"icons/"` for Svelte apps.
199
+ * - `"https://cdn.maptiler.com/maptiler-geocoding-control/v${version}/icons/"` for others.
197
200
  */
198
- reverseActive?: boolean;
201
+ iconsBaseUrl?: string;
199
202
  /**
200
- * Title of the reverse toggle button.
203
+ * Keeps the result list open even if the control is unfocused.
201
204
  *
202
- * Default value is `"toggle reverse geocoding"`.
205
+ * Default: `false`.
203
206
  */
204
- reverseButtonTitle?: string;
207
+ keepListOpen?: boolean;
205
208
  /**
206
- * 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.
207
212
  *
208
- * Default value is `"clear"`.
213
+ * Default: `undefined` (uses the browser's language settings).
209
214
  */
210
- clearButtonTitle?: string;
215
+ language?: string | string[] | null;
211
216
  /**
212
- * Set to `"never"` to hide place/POI type. If set to `"always"` then type is shown for all items.
213
- * 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.
214
220
  *
215
- * Default value is `"if-needed"`.
221
+ * Default: `5`.
216
222
  */
217
- showPlaceType?: ShowPlaceType;
223
+ limit?: number;
218
224
  /**
219
- * Style of the picked result on the map:
225
+ * Displays a marker on the selected feature from the result list.
220
226
  *
221
- * - `"marker-only"` - show only marker at the center of the feature
222
- * - `"full-geometry"` - show full feature geometry of the chosen result
223
- * - `"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.
224
232
  *
225
- * Default value is `true`.
233
+ * Default: `2`.
226
234
  */
227
- pickedResultStyle?: PickedResultStyle;
235
+ minLength?: number;
228
236
  /**
229
- * Limit search to specified country(ies).
237
+ * Custom message for when no results are found.
230
238
  *
231
- * 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
+ * ```
232
245
  */
233
- country?: string | string[];
246
+ noResultsMessage?: string;
234
247
  /**
235
- * 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.
236
252
  *
237
- * Default value is `undefined` - all available feature types are returned.
253
+ * Default: `"full-geometry"`.
238
254
  */
239
- types?: string[];
255
+ pickedResultStyle?: PickedResultStyle;
240
256
  /**
241
- * Use `limit` value for reverse geocoding even if `types` is not an array with a single element.
242
- * Will work only if enabled on the server.
257
+ * Custom placeholder for the input box.
243
258
  *
244
- * Default value is `false`.
259
+ * Default: `"Search"`.
245
260
  */
246
- exhaustiveReverseGeocoding?: boolean;
261
+ placeholder?: string;
247
262
  /**
248
- * 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.
249
266
  *
250
- * Default value is `false`.
267
+ * Default: `[ { type: "server-geolocation" } ]`.
251
268
  */
252
- excludeTypes?: boolean;
269
+ proximity?: ProximityRule[] | null;
253
270
  /**
254
- * Geocoding API URL.
271
+ * Activates reverse geocoding.
255
272
  *
256
- * Default value is MapTiler Geocoding API URL.
273
+ * Default: `false`.
257
274
  */
258
- apiUrl?: string;
275
+ reverseActive?: boolean;
259
276
  /**
260
- * Extra fetch parameters.
277
+ * Title of the reverse geocoding toggle button.
261
278
  *
262
- * Default value is `undefined`.
279
+ * Default: `"toggle reverse geocoding"`.
263
280
  */
264
- fetchParameters?: RequestInit;
281
+ reverseButtonTitle?: string;
265
282
  /**
266
- * Base URL for POI icons.
283
+ * Excludes types for reverse geocoding.
267
284
  *
268
- * Default value is `"icons/"` for Svelte apps, otherwise `"https://cdn.maptiler.com/maptiler-geocoding-control/v${version}/icons/"`.
285
+ * Default: Same as `excludeTypes`.
269
286
  */
270
- iconsBaseUrl?: string;
287
+ reverseGeocodingExcludeTypes?: boolean;
271
288
  /**
272
- * 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.
273
291
  *
274
- * Default value is empty function.
292
+ * See also `reverseGeocodingTypes` option.
275
293
  *
276
- * @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.
277
295
  */
278
- adjustUrlQuery?: (sp: URLSearchParams) => void;
296
+ reverseGeocodingLimit?: number;
279
297
  /**
280
- * 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.
281
301
  *
282
- * @param url [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL) parameter which can be modified
302
+ * See also `reverseGeocodingLimit` option.
283
303
  *
284
- * Default value is empty function.
304
+ * Default: Same as `types`.
285
305
  */
286
- adjustUrl?: (url: URL) => void;
306
+ reverseGeocodingTypes?: TypeRule[];
287
307
  /**
288
- * Automatically select the first feature from the result list.
308
+ * Automatically selects the first feature in the result list.
289
309
  *
290
- * Default value is `true`.
310
+ * Default: `true`.
291
311
  */
292
312
  selectFirst?: boolean;
293
313
  /**
294
- * 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.
295
318
  *
296
- * Default value is `false`.
319
+ * Default: `"if-needed"`.
297
320
  */
298
- flyToSelected?: boolean;
321
+ showPlaceType?: ShowPlaceType;
299
322
  /**
300
- * 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.
301
326
  *
302
- * Default value is `true`.
327
+ * Default: `false`.
303
328
  */
304
- 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>;
305
348
  };
306
349
  export type PickedResultStyle = "marker-only" | "full-geometry" | "full-geometry-including-polygon-center-marker";
307
350
  export type EnableReverse = "never" | "always" | "button";
@@ -341,3 +384,8 @@ export type RedefineType<OriginalType, UpdatedType extends {
341
384
  } & {
342
385
  [K in Exclude<keyof UpdatedType, keyof OriginalType>]: never;
343
386
  }> = UpdatedType;
387
+ export type TypeRule = string | [
388
+ minZoom: number | null | undefined,
389
+ maxZoom: number | null | undefined,
390
+ type: string
391
+ ];