@maptiler/geocoding-control 0.0.31

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.
@@ -0,0 +1,198 @@
1
+ export type Feature = {
2
+ id: string;
3
+ text: string;
4
+ place_name: string;
5
+ place_type: string;
6
+ center: [number, number];
7
+ bbox: [number, number, number, number];
8
+ };
9
+
10
+ export type FeatureCollection = {
11
+ features: Feature[];
12
+ };
13
+
14
+ export type MapController = {
15
+ setProximityChangeHandler(
16
+ proximityChangeHandler:
17
+ | undefined
18
+ | ((proximity: [number, number] | undefined) => void)
19
+ ): void;
20
+
21
+ setMapClickHandler(
22
+ mapClickHandler: undefined | ((coordinates: [number, number]) => void)
23
+ ): void;
24
+
25
+ flyTo(center: [number, number], zoom: number): void;
26
+
27
+ fitBounds(bbox: [number, number, number, number], padding: number): void;
28
+
29
+ indicateReverse(reverse: boolean): void;
30
+
31
+ setMarkers(
32
+ features: Feature[] | undefined,
33
+ picked: Feature | undefined
34
+ ): void;
35
+
36
+ setSelectedMarker(index: number): void;
37
+ };
38
+
39
+ export type Proximity = [number, number] | undefined;
40
+
41
+ export type ControlOptions = {
42
+ /**
43
+ * Maptiler API key
44
+ */
45
+ apiKey: string;
46
+
47
+ /**
48
+ * Sets the amount of time, in milliseconds, to wait before querying the server when a user types into the Geocoder input box.
49
+ * This parameter may be useful for reducing the total number of API calls made for a single query.
50
+ *
51
+ * @default 200
52
+ */
53
+ debounceSearch?: number;
54
+
55
+ /**
56
+ * A proximity argument: this is a geographical point given as an object with latitude and longitude properties.
57
+ * Search results closer to this point will be given higher priority.
58
+ */
59
+ proximity?: [number, number];
60
+
61
+ /**
62
+ * Override the default placeholder attribute value.
63
+ *
64
+ * @default "Search"
65
+ */
66
+ placeholder?: string;
67
+
68
+ /**
69
+ * Override the default error message.
70
+ *
71
+ * @default "Searching failed"
72
+ */
73
+ errorMessage?: string;
74
+
75
+ /**
76
+ * Override the default message if no results are found.
77
+ *
78
+ * @default "No results found"
79
+ */
80
+ noResultsMessage?: string;
81
+
82
+ /**
83
+ * If true, the geocoder proximity will automatically update based on the map view.
84
+ *
85
+ * @default true
86
+ */
87
+ trackProximity?: boolean;
88
+
89
+ /**
90
+ * Minimum number of characters to enter before results are shown.
91
+ *
92
+ * @default 2
93
+ */
94
+ minLength?: number;
95
+
96
+ /**
97
+ * A bounding box argument: this is a bounding box given as an array in the format [minX, minY, maxX, maxY].
98
+ * Search results will be limited to the bounding box.
99
+ */
100
+ bbox?: [number, number, number, number];
101
+
102
+ // /**
103
+ // * Maximum number of results to show.
104
+ // *
105
+ // * @default 5
106
+ // */
107
+ // limit?: number;
108
+
109
+ /**
110
+ * Specify the language to use for response text and query result weighting.
111
+ * 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.
112
+ * More than one value can also be specified, separated by commas.
113
+ * Defaults to the browser's language settings.
114
+ */
115
+ language?: string;
116
+
117
+ /**
118
+ * If `false`, indicates that search will only occur on enter key press.
119
+ * If `true`, indicates that the Geocoder will search on the input box being updated above the minLength option.
120
+ *
121
+ * @default false
122
+ */
123
+ showResultsWhileTyping?: boolean;
124
+
125
+ // /**
126
+ // * Set to `false` to disable autocomplete.
127
+ // *
128
+ // * @default true
129
+ // */
130
+ // autocomplete?: boolean;
131
+
132
+ // /**
133
+ // * Set to `false` to disable fuzzy search.
134
+ // *
135
+ // * @default true
136
+ // */
137
+ // fuzzy?: boolean;
138
+
139
+ /**
140
+ * On geocoded result what zoom level should the map animate to when a bbox isn't found in the response.
141
+ * If a bbox is found the map will fit to the bbox.
142
+ *
143
+ * @default 16
144
+ */
145
+ zoom?: number;
146
+
147
+ /**
148
+ * If `true`, the geocoder control will collapse until hovered or in focus.
149
+ *
150
+ * @default false
151
+ */
152
+ collapsed?: boolean;
153
+
154
+ // /**
155
+ // * If `true`, the geocoder control will clear it's contents and blur when user presses the escape key.
156
+ // *
157
+ // * @default false
158
+ // */
159
+ // clearAndBlurOnEsc?: boolean;
160
+
161
+ /**
162
+ * If true, the geocoder control will clear its value when the input blurs.
163
+ *
164
+ * @default false
165
+ */
166
+ clearOnBlur?: boolean;
167
+
168
+ /**
169
+ * 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.
170
+ * Return true to keep the item, false otherwise.
171
+ */
172
+ filter?: (feature: Feature) => boolean;
173
+
174
+ /**
175
+ * Class of the root element.
176
+ */
177
+ class?: string;
178
+
179
+ /**
180
+ * Set to `true` to enable reverse geocoding button with title _toggle reverse geocoding_ or set the button title directly.
181
+ *
182
+ * @default false
183
+ */
184
+ enableReverse?: boolean | string;
185
+
186
+ /**
187
+ * Set to `true` to show place type.
188
+ *
189
+ * @default false
190
+ */
191
+ showPlaceType?: boolean;
192
+
193
+ // TODO - missing but useful from maplibre-gl-geocoder
194
+ // popup // If true, a Popup will be added to the map when clicking on a marker using a default set of popup options. If the value is an object, the popup will be constructed using these options. If false, no popup will be added to the map. Requires that options.maplibregl also be set. (optional, default true)
195
+ // render // A function that specifies how the results should be rendered in the dropdown menu. This function should accepts a single Carmen GeoJSON object as input and return a string. Any HTML in the returned string will be rendered.
196
+ // popupRender // A function that specifies how the results should be rendered in the popup menu. This function should accept a single Carmen GeoJSON object as input and return a string. Any HTML in the returned string will be rendered.
197
+ // getItemValue // A function that specifies how the selected result should be rendered in the search bar. This function should accept a single Carmen GeoJSON object as input and return a string. HTML tags in the output string will not be rendered. Defaults to (item) => item.place_name.
198
+ };