@maptiler/geocoding-control 2.0.0 → 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.
- package/MapLibreBasedGeocodingControl.d.ts +3027 -27
- package/icons/10pin.svg +4 -1
- package/icons/9pin.svg +4 -1
- package/icons/alcohol.svg +1 -1
- package/icons/alpine_hut.svg +1 -1
- package/icons/apartment.svg +4 -1
- package/icons/area.svg +1 -5
- package/icons/artwork.svg +4 -1
- package/icons/beauty.svg +14 -1
- package/icons/bicycle_repair_station.svg +18 -1
- package/icons/biergarten.svg +4 -1
- package/icons/books.svg +14 -1
- package/icons/bowl.svg +4 -1
- package/icons/bowling_alley.svg +4 -1
- package/icons/bus_station.svg +1 -1
- package/icons/camping.svg +1 -1
- package/icons/car_repair.svg +14 -1
- package/icons/car_wash.svg +19 -1
- package/icons/cave_entrance.svg +15 -1
- package/icons/chalet.svg +1 -1
- package/icons/chemist.svg +14 -1
- package/icons/church.svg +4 -1
- package/icons/community_centre.svg +20 -1
- package/icons/firestation.svg +4 -1
- package/icons/guest_house.svg +29 -8
- package/icons/hotel.svg +1 -1
- package/icons/housenumber.svg +19 -14
- package/icons/hut.svg +1 -4
- package/icons/medical_supply.svg +20 -1
- package/icons/memorial.svg +14 -1
- package/icons/motel.svg +19 -1
- package/icons/post.svg +1 -1
- package/icons/post_office.svg +1 -1
- package/icons/postal_code.svg +1 -23
- package/icons/public_bookcase.svg +14 -1
- package/icons/public_building.svg +4 -1
- package/icons/shintoist.svg +1 -1
- package/icons/street.svg +11 -14
- package/icons/vehicle_inspection.svg +18 -1
- package/icons/wilderness_hut.svg +1 -1
- package/leaflet-controller.d.ts +1 -1
- package/leaflet-controller.js +113 -110
- package/leaflet-controller.js.map +1 -1
- package/leaflet-controller.umd.js +2 -2
- package/leaflet-controller.umd.js.map +1 -1
- package/leaflet.d.ts +58 -5
- package/leaflet.js +1438 -1265
- package/leaflet.js.map +1 -1
- package/leaflet.umd.js +3 -3
- package/leaflet.umd.js.map +1 -1
- package/maplibregl-controller.d.ts +1 -1
- package/maplibregl-controller.js +483 -469
- package/maplibregl-controller.js.map +1 -1
- package/maplibregl-controller.umd.js +3 -3
- package/maplibregl-controller.umd.js.map +1 -1
- package/maplibregl.d.ts +2499 -13
- package/maplibregl.js +2435 -2139
- package/maplibregl.js.map +1 -1
- package/maplibregl.umd.js +3 -3
- package/maplibregl.umd.js.map +1 -1
- package/maptilersdk.d.ts +2499 -13
- package/maptilersdk.js +2432 -2139
- package/maptilersdk.js.map +1 -1
- package/maptilersdk.umd.js +3 -3
- package/maptilersdk.umd.js.map +1 -1
- package/openlayers-controller.d.ts +1 -1
- package/openlayers-controller.js +66 -63
- package/openlayers-controller.js.map +1 -1
- package/openlayers-controller.umd.js +2 -2
- package/openlayers-controller.umd.js.map +1 -1
- package/openlayers.d.ts +53 -1
- package/openlayers.js +2046 -1902
- package/openlayers.js.map +1 -1
- package/openlayers.umd.js +3 -3
- package/openlayers.umd.js.map +1 -1
- package/package.json +28 -28
- package/react.d.ts +31 -5
- package/react.js +1252 -1096
- package/react.js.map +1 -1
- package/react.umd.js +1 -1
- package/react.umd.js.map +1 -1
- package/style.css +1 -1
- package/svelte/FeatureItem.svelte +60 -13
- package/svelte/FeatureItem.svelte.d.ts +4 -4
- package/svelte/GeocodingControl.svelte +166 -98
- package/svelte/GeocodingControl.svelte.d.ts +36 -16
- package/svelte/MapLibreBasedGeocodingControl.d.ts +3027 -27
- package/svelte/MapLibreBasedGeocodingControl.js +154 -21
- package/svelte/leaflet-controller.d.ts +1 -1
- package/svelte/leaflet-controller.js +6 -3
- package/svelte/leaflet.d.ts +58 -5
- package/svelte/leaflet.js +52 -21
- package/svelte/maplibregl-controller.d.ts +1 -1
- package/svelte/maplibregl-controller.js +47 -38
- package/svelte/maplibregl.d.ts +2499 -13
- package/svelte/maplibregl.js +11 -3
- package/svelte/maptilersdk.d.ts +2499 -13
- package/svelte/maptilersdk.js +11 -3
- package/svelte/openlayers-controller.d.ts +1 -1
- package/svelte/openlayers-controller.js +7 -4
- package/svelte/openlayers.d.ts +53 -1
- package/svelte/openlayers.js +66 -48
- package/svelte/react.d.ts +31 -5
- package/svelte/react.js +21 -9
- package/svelte/types.d.ts +106 -35
- package/svelte/vanilla.d.ts +46 -2
- package/svelte/vanilla.js +66 -10
- package/types.d.ts +106 -35
- package/vanilla.d.ts +46 -2
- package/vanilla.js +1260 -1057
- package/vanilla.js.map +1 -1
- package/vanilla.umd.js +1 -1
- package/vanilla.umd.js.map +1 -1
- package/icons/aerodrome.12.svg +0 -1
- package/icons/bus_stop.12.svg +0 -1
- package/icons/elevator.12.svg +0 -1
- /package/icons/{helipad.16.svg → helipad.svg} +0 -0
- /package/icons/{traffic_light.13.svg → traffic_light.svg} +0 -0
package/svelte/types.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export type MapController = {
|
|
|
33
33
|
flyTo(center: Position, zoom?: number): void;
|
|
34
34
|
fitBounds(bbox: BBox, padding: number, maxZoom?: number): void;
|
|
35
35
|
indicateReverse(reverse: boolean): void;
|
|
36
|
-
|
|
36
|
+
setFeatures(features: Feature[] | undefined, picked: Feature | undefined, showPolygonMarker: boolean): void;
|
|
37
37
|
setReverseMarker(coordinates?: Position): void;
|
|
38
38
|
setSelectedMarker(index: number): void;
|
|
39
39
|
getCenterAndZoom(): [zoom: number, lon: number, lat: number] | undefined;
|
|
@@ -68,43 +68,51 @@ export type ControlOptions = {
|
|
|
68
68
|
/**
|
|
69
69
|
* Sets the amount of time, in milliseconds, to wait before querying the server when a user types into the Geocoder input box.
|
|
70
70
|
* This parameter may be useful for reducing the total number of API calls made for a single query.
|
|
71
|
+
*
|
|
71
72
|
* Default value is `200`.
|
|
72
73
|
*/
|
|
73
74
|
debounceSearch?: number;
|
|
74
75
|
/**
|
|
75
76
|
* Search results closer to the proximity point will be given higher priority. First matching rule from the array will be used.
|
|
76
77
|
* Set to `null` to disable the proximity.
|
|
78
|
+
*
|
|
77
79
|
* Default value is `[{ type: "server-geolocation" }]`.
|
|
78
80
|
*/
|
|
79
81
|
proximity?: ProximityRule[] | null;
|
|
80
82
|
/**
|
|
81
83
|
* Override the default placeholder attribute value.
|
|
84
|
+
*
|
|
82
85
|
* Default value is `"Search"`.
|
|
83
86
|
*/
|
|
84
87
|
placeholder?: string;
|
|
85
88
|
/**
|
|
86
89
|
* Override the default error message.
|
|
90
|
+
*
|
|
87
91
|
* Default value is `"Something went wrong…"`.
|
|
88
92
|
*/
|
|
89
93
|
errorMessage?: string;
|
|
90
94
|
/**
|
|
91
95
|
* Override the default message if no results are found.
|
|
96
|
+
*
|
|
92
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!"`.
|
|
93
98
|
*/
|
|
94
99
|
noResultsMessage?: string;
|
|
95
100
|
/**
|
|
96
101
|
* Minimum number of characters to enter before results are shown.
|
|
102
|
+
*
|
|
97
103
|
* Default value is `2`.
|
|
98
104
|
*/
|
|
99
105
|
minLength?: number;
|
|
100
106
|
/**
|
|
101
107
|
* A bounding box argument: this is a bounding box given as an array in the format [minX, minY, maxX, maxY].
|
|
102
108
|
* Search results will be limited to the bounding box.
|
|
109
|
+
*
|
|
103
110
|
* Default value is `undefined`.
|
|
104
111
|
*/
|
|
105
112
|
bbox?: BBox;
|
|
106
113
|
/**
|
|
107
114
|
* Maximum number of results to show.
|
|
115
|
+
*
|
|
108
116
|
* Default value is `5`.
|
|
109
117
|
*/
|
|
110
118
|
limit?: number;
|
|
@@ -113,131 +121,169 @@ export type ControlOptions = {
|
|
|
113
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.
|
|
114
122
|
* More than one value can also be specified, separated by commas.
|
|
115
123
|
* Set to `null` or empty string for disabling language-specific searching.
|
|
116
|
-
*
|
|
117
|
-
* Default value is `undefined
|
|
124
|
+
*
|
|
125
|
+
* Default value is `undefined` which means to use the browser's language settings.
|
|
118
126
|
*/
|
|
119
127
|
language?: string | string[] | null;
|
|
120
128
|
/**
|
|
121
129
|
* If `false`, indicates that search will only occur on enter key press.
|
|
122
130
|
* If `true`, indicates that the Geocoder will search on the input box being updated above the minLength option.
|
|
131
|
+
*
|
|
123
132
|
* Default value is `false`.
|
|
124
133
|
*/
|
|
125
134
|
showResultsWhileTyping?: boolean;
|
|
126
135
|
/**
|
|
127
136
|
* Set to `false` to disable fuzzy search.
|
|
128
|
-
*
|
|
137
|
+
*
|
|
138
|
+
* Default value is `true`.
|
|
129
139
|
*/
|
|
130
140
|
fuzzyMatch?: boolean;
|
|
131
141
|
/**
|
|
132
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.
|
|
133
143
|
* If a bbox is present and not a point then the map will fit to the bbox.
|
|
134
144
|
*
|
|
135
|
-
* Value
|
|
145
|
+
* Value is key-value pairs, where key is a <type> or <type>.<categoy> and the value is the zoom level.
|
|
136
146
|
*
|
|
137
147
|
* Default value is `GeocodingControl.ZOOM_DEFAULTS`.
|
|
138
148
|
*/
|
|
139
|
-
zoom?:
|
|
149
|
+
zoom?: Record<string, number>;
|
|
140
150
|
/**
|
|
141
|
-
*
|
|
142
|
-
* Used for small features.
|
|
151
|
+
* If `true`, the geocoder control will collapse until hovered or in focus.
|
|
143
152
|
*
|
|
144
|
-
*
|
|
153
|
+
* Default value is `false`.
|
|
154
|
+
*/
|
|
155
|
+
collapsed?: boolean;
|
|
156
|
+
/**
|
|
157
|
+
* If `true`, the geocoder control will clear its value when the input blurs.
|
|
145
158
|
*
|
|
146
|
-
*
|
|
159
|
+
* Default value is `false`.
|
|
147
160
|
*/
|
|
148
|
-
|
|
161
|
+
clearOnBlur?: boolean;
|
|
149
162
|
/**
|
|
150
|
-
* If `true`, the
|
|
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
|
+
*
|
|
151
165
|
* Default value is `false`.
|
|
152
166
|
*/
|
|
153
|
-
|
|
167
|
+
clearListOnPick?: boolean;
|
|
154
168
|
/**
|
|
155
|
-
*
|
|
169
|
+
* Keep the list open even if the control is not focused.
|
|
170
|
+
*
|
|
156
171
|
* Default value is `false`.
|
|
157
172
|
*/
|
|
158
|
-
|
|
173
|
+
keepListOpen?: boolean;
|
|
159
174
|
/**
|
|
160
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.
|
|
161
176
|
* Return true to keep the item, false otherwise.
|
|
177
|
+
*
|
|
178
|
+
* Default value is a function returning always `true`.
|
|
162
179
|
*/
|
|
163
180
|
filter?: (feature: Feature) => boolean;
|
|
164
181
|
/**
|
|
165
182
|
* Class of the root element.
|
|
183
|
+
*
|
|
166
184
|
* Default value is `undefined`.
|
|
167
185
|
*/
|
|
168
186
|
class?: string;
|
|
169
187
|
/**
|
|
170
|
-
* Set to `
|
|
171
|
-
*
|
|
188
|
+
* Set to `button` to enable reverse geocoding button with title. Set to `"always"` to reverse geocoding be always active.
|
|
189
|
+
*
|
|
190
|
+
* Default value is `"never"`.
|
|
172
191
|
*/
|
|
173
|
-
enableReverse?:
|
|
192
|
+
enableReverse?: EnableReverse;
|
|
174
193
|
/**
|
|
175
|
-
*
|
|
194
|
+
* Reverse mode active.
|
|
195
|
+
*
|
|
176
196
|
* Default value is `false`.
|
|
177
197
|
*/
|
|
178
198
|
reverseActive?: boolean;
|
|
179
199
|
/**
|
|
180
|
-
*
|
|
200
|
+
* Title of the reverse toggle button.
|
|
201
|
+
*
|
|
181
202
|
* Default value is `"toggle reverse geocoding"`.
|
|
182
203
|
*/
|
|
183
204
|
reverseButtonTitle?: string;
|
|
184
205
|
/**
|
|
185
|
-
*
|
|
206
|
+
* Title of the clear button.
|
|
207
|
+
*
|
|
186
208
|
* Default value is `"clear"`.
|
|
187
209
|
*/
|
|
188
210
|
clearButtonTitle?: string;
|
|
189
211
|
/**
|
|
190
|
-
* Set to `
|
|
191
|
-
* If set to `"
|
|
192
|
-
*
|
|
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.
|
|
214
|
+
*
|
|
215
|
+
* Default value is `"if-needed"`.
|
|
193
216
|
*/
|
|
194
|
-
showPlaceType?:
|
|
217
|
+
showPlaceType?: ShowPlaceType;
|
|
195
218
|
/**
|
|
196
|
-
*
|
|
219
|
+
* Style of the picked result on the map:
|
|
220
|
+
*
|
|
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
|
|
224
|
+
*
|
|
197
225
|
* Default value is `true`.
|
|
198
226
|
*/
|
|
199
|
-
|
|
227
|
+
pickedResultStyle?: PickedResultStyle;
|
|
200
228
|
/**
|
|
201
229
|
* Limit search to specified country(ies).
|
|
230
|
+
*
|
|
202
231
|
* Default value is `undefined` - use all countries.
|
|
203
232
|
*/
|
|
204
233
|
country?: string | string[];
|
|
205
234
|
/**
|
|
206
235
|
* Filter of feature types to return.
|
|
236
|
+
*
|
|
207
237
|
* Default value is `undefined` - all available feature types are returned.
|
|
208
238
|
*/
|
|
209
239
|
types?: string[];
|
|
210
240
|
/**
|
|
211
241
|
* Use `limit` value for reverse geocoding even if `types` is not an array with a single element.
|
|
212
242
|
* Will work only if enabled on the server.
|
|
243
|
+
*
|
|
213
244
|
* Default value is `false`.
|
|
214
245
|
*/
|
|
215
246
|
exhaustiveReverseGeocoding?: boolean;
|
|
216
247
|
/**
|
|
217
248
|
* If set to `true` then use all types except for those listed in `types`.
|
|
249
|
+
*
|
|
218
250
|
* Default value is `false`.
|
|
219
251
|
*/
|
|
220
252
|
excludeTypes?: boolean;
|
|
221
253
|
/**
|
|
222
254
|
* Geocoding API URL.
|
|
255
|
+
*
|
|
223
256
|
* Default value is MapTiler Geocoding API URL.
|
|
224
257
|
*/
|
|
225
258
|
apiUrl?: string;
|
|
226
259
|
/**
|
|
227
260
|
* Extra fetch parameters.
|
|
261
|
+
*
|
|
228
262
|
* Default value is `undefined`.
|
|
229
263
|
*/
|
|
230
264
|
fetchParameters?: RequestInit;
|
|
231
265
|
/**
|
|
232
266
|
* Base URL for POI icons.
|
|
267
|
+
*
|
|
233
268
|
* Default value is `"icons/"` for Svelte apps, otherwise `"https://cdn.maptiler.com/maptiler-geocoding-control/v${version}/icons/"`.
|
|
234
269
|
*/
|
|
235
270
|
iconsBaseUrl?: string;
|
|
236
271
|
/**
|
|
237
272
|
* Function to adjust URL search parameters.
|
|
273
|
+
*
|
|
238
274
|
* Default value is empty function.
|
|
275
|
+
*
|
|
276
|
+
* @deprecated use `adjustUrl`
|
|
239
277
|
*/
|
|
240
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;
|
|
241
287
|
/**
|
|
242
288
|
* Automatically select the first feature from the result list.
|
|
243
289
|
*
|
|
@@ -257,16 +303,41 @@ export type ControlOptions = {
|
|
|
257
303
|
*/
|
|
258
304
|
markerOnSelected?: boolean;
|
|
259
305
|
};
|
|
260
|
-
export type
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
306
|
+
export type PickedResultStyle = "marker-only" | "full-geometry" | "full-geometry-including-polygon-center-marker";
|
|
307
|
+
export type EnableReverse = "never" | "always" | "button";
|
|
308
|
+
export type ShowPlaceType = "never" | "always" | "if-needed";
|
|
309
|
+
export type DispatcherTypeCC = {
|
|
310
|
+
featuresListed: {
|
|
311
|
+
features: Feature[] | undefined;
|
|
312
|
+
};
|
|
313
|
+
featuresMarked: {
|
|
314
|
+
features: Feature[] | undefined;
|
|
315
|
+
};
|
|
316
|
+
optionsVisibilityChange: {
|
|
317
|
+
optionsVisible: boolean;
|
|
318
|
+
};
|
|
319
|
+
pick: {
|
|
320
|
+
feature: Feature | undefined;
|
|
321
|
+
};
|
|
322
|
+
queryChange: {
|
|
323
|
+
query: string;
|
|
324
|
+
};
|
|
266
325
|
response: {
|
|
267
326
|
url: string;
|
|
268
327
|
featureCollection: FeatureCollection;
|
|
269
328
|
};
|
|
270
|
-
reverseToggle:
|
|
271
|
-
|
|
329
|
+
reverseToggle: {
|
|
330
|
+
reverse: boolean;
|
|
331
|
+
};
|
|
332
|
+
select: {
|
|
333
|
+
feature: Feature | undefined;
|
|
334
|
+
};
|
|
335
|
+
};
|
|
336
|
+
export type DispatcherType = {
|
|
337
|
+
[T in keyof DispatcherTypeCC as Lowercase<T>]: DispatcherTypeCC[T];
|
|
272
338
|
};
|
|
339
|
+
export type RedefineType<OriginalType, UpdatedType extends {
|
|
340
|
+
[K in keyof OriginalType]: OriginalType[K];
|
|
341
|
+
} & {
|
|
342
|
+
[K in Exclude<keyof UpdatedType, keyof OriginalType>]: never;
|
|
343
|
+
}> = UpdatedType;
|
package/svelte/vanilla.d.ts
CHANGED
|
@@ -1,17 +1,61 @@
|
|
|
1
|
-
import type { ControlOptions, MapController } from "./types";
|
|
1
|
+
import type { ControlOptions, DispatcherType, MapController } from "./types";
|
|
2
2
|
type Options = ControlOptions & {
|
|
3
3
|
mapController?: MapController;
|
|
4
4
|
};
|
|
5
|
+
interface GeocodingControlEvent<T> extends CustomEvent<T> {
|
|
6
|
+
readonly target: GeocodingControl;
|
|
7
|
+
readonly currentTarget: GeocodingControl;
|
|
8
|
+
}
|
|
9
|
+
type CustomEventListenerOrEventListenerObject<K extends keyof CustomEventMap> = ((evt: CustomEventMap[K]) => void) | {
|
|
10
|
+
handleEvent(object: CustomEventMap[K]): void;
|
|
11
|
+
};
|
|
12
|
+
type CustomEventMap = {
|
|
13
|
+
[T in keyof DispatcherType]: GeocodingControlEvent<DispatcherType[T]>;
|
|
14
|
+
};
|
|
5
15
|
export declare class GeocodingControl extends EventTarget {
|
|
6
16
|
#private;
|
|
7
17
|
constructor({ target, ...options }: Options & {
|
|
8
18
|
target: HTMLElement;
|
|
9
19
|
});
|
|
20
|
+
/**
|
|
21
|
+
* Update the control options.
|
|
22
|
+
*
|
|
23
|
+
* @param options options to update
|
|
24
|
+
*/
|
|
10
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
|
+
*/
|
|
11
32
|
setQuery(value: string, submit?: boolean): void;
|
|
33
|
+
/**
|
|
34
|
+
* Clear geocoding search results from the map.
|
|
35
|
+
*/
|
|
12
36
|
clearMap(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Clear search result list.
|
|
39
|
+
*/
|
|
13
40
|
clearList(): void;
|
|
14
|
-
|
|
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
|
+
*/
|
|
15
56
|
blur(): void;
|
|
57
|
+
addEventListener<K extends keyof CustomEventMap>(type: K, callback: CustomEventListenerOrEventListenerObject<K> | null, options?: AddEventListenerOptions | boolean): void;
|
|
58
|
+
removeEventListener<K extends keyof CustomEventMap>(type: K, callback: CustomEventListenerOrEventListenerObject<K> | null, options?: EventListenerOptions | boolean): void;
|
|
59
|
+
dispatchEvent<K extends keyof CustomEventMap>(event: CustomEventMap[K]): boolean;
|
|
16
60
|
}
|
|
17
61
|
export {};
|
package/svelte/vanilla.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import GeocodingControlComponent from "./GeocodingControl.svelte";
|
|
2
2
|
const finalizationRegistry = new FinalizationRegistry((gc) => {
|
|
3
3
|
gc.$destroy();
|
|
4
4
|
});
|
|
@@ -6,40 +6,96 @@ export class GeocodingControl extends EventTarget {
|
|
|
6
6
|
#gc;
|
|
7
7
|
constructor({ target, ...options }) {
|
|
8
8
|
super();
|
|
9
|
-
this.#gc = new
|
|
9
|
+
this.#gc = new GeocodingControlComponent({
|
|
10
10
|
target,
|
|
11
11
|
props: options,
|
|
12
12
|
});
|
|
13
13
|
for (const eventName of [
|
|
14
14
|
"select",
|
|
15
15
|
"pick",
|
|
16
|
-
"
|
|
17
|
-
"
|
|
16
|
+
"featureslisted",
|
|
17
|
+
"featuresmarked",
|
|
18
18
|
"response",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
19
|
+
"optionsvisibilitychange",
|
|
20
|
+
"reversetoggle",
|
|
21
|
+
"querychange",
|
|
22
22
|
]) {
|
|
23
|
-
this.#gc.$on(eventName, (event) =>
|
|
23
|
+
this.#gc.$on(eventName, (event) => {
|
|
24
|
+
// Use the new `emit` method for type-safe dispatching
|
|
25
|
+
this.#emit(eventName, event.detail);
|
|
26
|
+
});
|
|
24
27
|
}
|
|
28
|
+
this.#gc.$on("select", (event) => {
|
|
29
|
+
const geocodingEvent = new CustomEvent(event.type, {
|
|
30
|
+
detail: event.detail,
|
|
31
|
+
});
|
|
32
|
+
this.dispatchEvent(geocodingEvent);
|
|
33
|
+
});
|
|
25
34
|
finalizationRegistry.register(this, this.#gc);
|
|
26
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Update the control options.
|
|
38
|
+
*
|
|
39
|
+
* @param options options to update
|
|
40
|
+
*/
|
|
27
41
|
setOptions(options) {
|
|
28
42
|
this.#gc.$set(options);
|
|
29
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Set the content of search input box.
|
|
46
|
+
*
|
|
47
|
+
* @param value text to set
|
|
48
|
+
* @param submit perform the search
|
|
49
|
+
*/
|
|
30
50
|
setQuery(value, submit = true) {
|
|
31
51
|
this.#gc?.setQuery(value, submit);
|
|
32
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Clear geocoding search results from the map.
|
|
55
|
+
*/
|
|
33
56
|
clearMap() {
|
|
34
57
|
this.#gc?.clearMap();
|
|
35
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Clear search result list.
|
|
61
|
+
*/
|
|
36
62
|
clearList() {
|
|
37
63
|
this.#gc?.clearList();
|
|
38
64
|
}
|
|
39
|
-
|
|
40
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Set reverse geocoding mode.
|
|
67
|
+
*
|
|
68
|
+
* @param reverseActive reverse geocoding active
|
|
69
|
+
*/
|
|
70
|
+
setReverseMode(reverseActive) {
|
|
71
|
+
this.#gc?.$set({ reverseActive });
|
|
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);
|
|
41
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Blur the search input box.
|
|
83
|
+
*/
|
|
42
84
|
blur() {
|
|
43
85
|
this.#gc?.blur();
|
|
44
86
|
}
|
|
87
|
+
addEventListener(type, callback, options) {
|
|
88
|
+
super.addEventListener(type, callback, options);
|
|
89
|
+
}
|
|
90
|
+
removeEventListener(type, callback, options) {
|
|
91
|
+
super.removeEventListener(type, callback, options);
|
|
92
|
+
}
|
|
93
|
+
dispatchEvent(event) {
|
|
94
|
+
return super.dispatchEvent(event);
|
|
95
|
+
}
|
|
96
|
+
#emit(type, detail) {
|
|
97
|
+
return super.dispatchEvent(new CustomEvent(type, {
|
|
98
|
+
detail,
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
45
101
|
}
|