@@ -8,10 +8,13 @@ declare class AbstractPlaces {
8
8
constructor ( options : JawgPlaces . JawgPlacesOptions ) ;
9
9
/**
10
10
* Search a random text or lat/lon using Jawg Places.
11
+ *
11
12
* All features are points with properties, more details on our [documentation](https://www.jawg.io/docs/apidocs/places/response).
12
13
*
13
- * @param text to search using Jawg Places
14
- * @returns promise with the feature collection received from Jawg Places
14
+ * See {@link JawgPlacesOptions.reverse} for lat/lon search.
15
+ *
16
+ * @param text The text to search using Jawg Places
17
+ * @returns A promise with the feature collection received from Jawg Places
15
18
*/
16
19
search ( text : string ) : Promise < JawgPlaces . FeatureCollection > ;
17
20
/**
@@ -48,6 +51,10 @@ declare class AbstractPlaces {
48
51
destroy ( ) : void ;
49
52
}
50
53
54
+ /**
55
+ * Welcome to Jawg Places type documentation.
56
+ * Checkout our examples on our [documentation website](https://www.jawg.io/docs/integration/places-js/) and the source code on [GitHub](https://github.com/jawg/places-js-examples).
57
+ */
51
58
declare namespace JawgPlaces {
52
59
/**
53
60
* Representation of geographic coordinate using the spatial reference World Geodetic System (WSG84, also known as EPSG:4326).
@@ -67,8 +74,19 @@ declare namespace JawgPlaces {
67
74
* Option to activate reverse geocoding withing the input.
68
75
* You can paste coordinates in the form {lat}/{lon} in the input.
69
76
* The separation can be either `/` (slash), `,` (comma) or ` ` (space).
77
+ * ```javascript
78
+ * new JawgPlaces({
79
+ * reverse: {
80
+ * enabled: true,
81
+ * radius: 50
82
+ * }
83
+ * })
84
+ * ```
70
85
*/
71
86
interface ReverseOptions {
87
+ /**
88
+ * Enable reverse geocoding in input.
89
+ */
72
90
enabled : boolean ;
73
91
/**
74
92
* Radius over the point in meters.
@@ -99,6 +117,15 @@ declare namespace JawgPlaces {
99
117
100
118
/**
101
119
* Set of options when you are looking for places in a particular region.
120
+ * ```javascript
121
+ * new JawgPlaces({
122
+ * boundaries: {
123
+ * countries: 'fra',
124
+ * point: { lat: 0, lon: 0 },
125
+ * gids: ['whosonfirst:locality:101751119']
126
+ * }
127
+ * })
128
+ * ```
102
129
*/
103
130
interface BoudaryOptions {
104
131
/**
@@ -109,12 +136,43 @@ declare namespace JawgPlaces {
109
136
* Search within a circular region. Circle can be static or dynamic with the function.
110
137
*/
111
138
circle : CircleOptions | ( ( ) => CircleOptions ) ;
139
+ /**
140
+ * Add a restriction by GIDs. GIDs can be static or dynamic with the function.
141
+ */
142
+ gids : string [ ] | string | ( ( ) => string [ ] ) | ( ( ) => string ) ;
112
143
/**
113
144
* Search within a rectangular region. Rectangle can be static or dynamic with the function.
114
145
*/
115
146
rectangle : RectangleOptions | ( ( ) => RectangleOptions ) ;
116
147
}
117
148
149
+ /**
150
+ * Set of options when you want to prioritize places from particular region.
151
+ * ```javascript
152
+ * new JawgPlaces({
153
+ * focus: {
154
+ * countries: 'fra',
155
+ * point: { lat: 0, lon: 0 },
156
+ * gids: ['whosonfirst:locality:101751119']
157
+ * }
158
+ * })
159
+ * ```
160
+ */
161
+ interface FocusOptions {
162
+ /**
163
+ * Add a priorities by alpha-2 or alpha-3 ISO-3166 country code. Countries can be static or dynamic with the function.
164
+ */
165
+ countries : string [ ] | string | ( ( ) => string [ ] ) | ( ( ) => string ) ;
166
+ /**
167
+ * Sort results in part by their proximity to the given coordinate. Coordinates can be static or dynamic with the function.
168
+ */
169
+ point ?: LatLon | ( ( ) => LatLon ) ;
170
+ /**
171
+ * Add a priorities by Jawg GIDs. GIDs can be static or dynamic with the function.
172
+ */
173
+ gids : string [ ] | string | ( ( ) => string [ ] ) | ( ( ) => string ) ;
174
+ }
175
+
118
176
/**
119
177
* Type of geometries used by Jawg Places API.
120
178
*/
@@ -140,14 +198,32 @@ declare namespace JawgPlaces {
140
198
| 'country'
141
199
| 'coarse'
142
200
| 'postalcode'
201
+ | 'island'
143
202
| string ;
203
+
144
204
/**
145
205
* All available sources.
146
206
*/
147
- type Source = 'wof' | 'whosonfirst' | 'oa' | 'openaddresses' | 'osm' | 'openstreetmap' | 'gn' | 'geonames' | string ;
207
+ type Source =
208
+ | 'wof'
209
+ | 'whosonfirst'
210
+ | 'oa'
211
+ | 'openaddresses'
212
+ | 'osm'
213
+ | 'openstreetmap'
214
+ | 'gn'
215
+ | 'geonames'
216
+ | 'jawg'
217
+ | string ;
148
218
149
219
/**
150
220
* Basic options for Places JS.
221
+ * ```javascript
222
+ * new JawgPlaces({
223
+ * accessToken: '<Access-Token>',
224
+ * input: '#my-input'
225
+ * })
226
+ * ```
151
227
*/
152
228
interface JawgPlacesOptions {
153
229
/**
@@ -184,14 +260,14 @@ declare namespace JawgPlaces {
184
260
* This option work only when `searchOnTyping=true`.
185
261
* Default value is `0`.
186
262
*/
187
- minLength ?: number ;
263
+ minLength ?: number ;
188
264
/**
189
265
* Set the number of milliseconds to wait before a search validation.
190
266
* If you press `Enter` the search will be immediately validated.
191
267
* This option work only when `searchOnTyping=true`.
192
268
* Default value is `350`.
193
269
*/
194
- debounceDelay ?: number ;
270
+ debounceDelay ?: number ;
195
271
/**
196
272
* Filter the kind of place you want to find. Layers can be static or dynamic with the function.
197
273
*/
@@ -201,7 +277,7 @@ declare namespace JawgPlaces {
201
277
*/
202
278
sources ?: Source [ ] | Source | ( ( ) => Source [ ] ) | ( ( ) => Source ) ;
203
279
/**
204
- * Sort results in part by their proximity to the given coordinate. Coordinates can be static or dynamic with the function.
280
+ * See { @link FocusOptions.point}
205
281
*/
206
282
focusPoint ?: LatLon | ( ( ) => LatLon ) ;
207
283
/**
@@ -228,7 +304,7 @@ declare namespace JawgPlaces {
228
304
reverse ?: ReverseOptions ;
229
305
/**
230
306
* Callback triggered when Jawg Places API returns without error.
231
- * @param features list of features returned by Jawg Places API
307
+ * @param features The list of features returned by Jawg Places API
232
308
*/
233
309
onFeatures ?: ( features : Feature [ ] ) => void ;
234
310
/**
@@ -237,7 +313,7 @@ declare namespace JawgPlaces {
237
313
onClose ?: ( ) => void ;
238
314
/**
239
315
* Callback triggered when the user click on a result.
240
- * @param feature selected by the user
316
+ * @param feature The feature selected by the user
241
317
*/
242
318
onClick ?: ( feature : Feature ) => void ;
243
319
/**
@@ -434,13 +510,13 @@ declare namespace JawgPlaces {
434
510
* This is the function used by MapLibre and Mapbox when you add a
435
511
* [maplibre.IControl](https://maplibre.org/maplibre-gl-js-docs/api/markers/#icontrol) or [mapboxgl.IControl](https://docs.mapbox.com/mapbox-gl-js/api/markers/#icontrol).
436
512
* Adds the control to the given map.
437
- * @param map from [MapLibre](https://maplibre.org/maplibre-gl-js-docs/api/map/) or [Mapbox](https://docs.mapbox.com/mapbox-gl-js/api/map/)
438
- * @returns the generated control container
513
+ * @param map The map from [MapLibre](https://maplibre.org/maplibre-gl-js-docs/api/map/) or [Mapbox](https://docs.mapbox.com/mapbox-gl-js/api/map/)
514
+ * @returns The generated control container
439
515
*/
440
516
onAdd ( map : maplibregl . Map | mapboxgl . Map ) : HTMLElement ;
441
517
/**
442
518
* When Jawg Places **is not used** as a control within your map, you will need to call this function.
443
- * @param map from [MapLibre](https://maplibre.org/maplibre-gl-js-docs/api/map/) or [Mapbox](https://docs.mapbox.com/mapbox-gl-js/api/map/)
519
+ * @param map The map from [MapLibre](https://maplibre.org/maplibre-gl-js-docs/api/map/) or [Mapbox](https://docs.mapbox.com/mapbox-gl-js/api/map/)
444
520
* @returns itself
445
521
*/
446
522
attachMap ( map : maplibregl . Map | mapboxgl . Map ) : MapLibre ;
@@ -454,6 +530,9 @@ declare namespace JawgPlaces {
454
530
* This class will help you to add or use search bar for geocoding with a Mapbox GL JS map.
455
531
*/
456
532
class Mapbox extends MapLibre {
533
+ /**
534
+ * @inheritdoc
535
+ */
457
536
attachMap ( map : maplibregl . Map | mapboxgl . Map ) : Mapbox ;
458
537
}
459
538
@@ -463,10 +542,9 @@ declare namespace JawgPlaces {
463
542
class Leaflet extends AbstractPlaces {
464
543
constructor ( options : JawgPlacesLeafletOptions ) ;
465
544
/**
466
- * This is the function used by Leaflet when you add a [L.Control](https://leafletjs.com/reference-1.7.1 .html#control).
545
+ * This is the function used by Leaflet when you add a [L.Control](https://leafletjs.com/reference.html#control).
467
546
* Adds the control to the given map.
468
- * @param map from [Leaflet](https://leafletjs.com/reference-1.7.1.html#map-example)
469
- * @returns the generated control container
547
+ * @param map The map from [Leaflet](https://leafletjs.com/reference.html#map-example)
470
548
*/
471
549
onAdd ( map : L . Map ) : void ;
472
550
/**
@@ -475,12 +553,12 @@ declare namespace JawgPlaces {
475
553
getPosition ( ) : string ;
476
554
/**
477
555
* Adds the control to the given map.
478
- * @param map from [Leaflet](https://leafletjs.com/reference-1.7.1 .html#map-example)
556
+ * @param map from [Leaflet](https://leafletjs.com/reference.html#map-example)
479
557
*/
480
558
addTo ( map : L . Map ) : void ;
481
559
/**
482
560
* When Jawg Places **is not used** as a control within your map, you will need to call this function.
483
- * @param map from [Leaflet](https://leafletjs.com/reference-1.7.1 .html#map-example)
561
+ * @param map from [Leaflet](https://leafletjs.com/reference.html#map-example)
484
562
* @returns itself
485
563
*/
486
564
attachMap ( map : L . Map ) : Leaflet ;
0 commit comments