Skip to content

Commit b1f92e3

Browse files
committed
feat(JawgPlaces): add support to focus.countries, focus.gids, boundary.gids and island layer
1 parent fad97d1 commit b1f92e3

File tree

3 files changed

+96
-18
lines changed

3 files changed

+96
-18
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@jawg/types",
3-
"version": "1.0.5",
3+
"version": "1.0.6",
44
"description": "Shared TypeScript definitions for Jawg Maps projects",
55
"types": "./index.d.ts",
66
"type": "module",

src/places-js.d.ts

Lines changed: 94 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ declare class AbstractPlaces {
88
constructor(options: JawgPlaces.JawgPlacesOptions);
99
/**
1010
* Search a random text or lat/lon using Jawg Places.
11+
*
1112
* All features are points with properties, more details on our [documentation](https://www.jawg.io/docs/apidocs/places/response).
1213
*
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
1518
*/
1619
search(text: string): Promise<JawgPlaces.FeatureCollection>;
1720
/**
@@ -48,6 +51,10 @@ declare class AbstractPlaces {
4851
destroy(): void;
4952
}
5053

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+
*/
5158
declare namespace JawgPlaces {
5259
/**
5360
* Representation of geographic coordinate using the spatial reference World Geodetic System (WSG84, also known as EPSG:4326).
@@ -67,8 +74,19 @@ declare namespace JawgPlaces {
6774
* Option to activate reverse geocoding withing the input.
6875
* You can paste coordinates in the form {lat}/{lon} in the input.
6976
* 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+
* ```
7085
*/
7186
interface ReverseOptions {
87+
/**
88+
* Enable reverse geocoding in input.
89+
*/
7290
enabled: boolean;
7391
/**
7492
* Radius over the point in meters.
@@ -99,6 +117,15 @@ declare namespace JawgPlaces {
99117

100118
/**
101119
* 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+
* ```
102129
*/
103130
interface BoudaryOptions {
104131
/**
@@ -109,12 +136,43 @@ declare namespace JawgPlaces {
109136
* Search within a circular region. Circle can be static or dynamic with the function.
110137
*/
111138
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);
112143
/**
113144
* Search within a rectangular region. Rectangle can be static or dynamic with the function.
114145
*/
115146
rectangle: RectangleOptions | (() => RectangleOptions);
116147
}
117148

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+
118176
/**
119177
* Type of geometries used by Jawg Places API.
120178
*/
@@ -140,14 +198,32 @@ declare namespace JawgPlaces {
140198
| 'country'
141199
| 'coarse'
142200
| 'postalcode'
201+
| 'island'
143202
| string;
203+
144204
/**
145205
* All available sources.
146206
*/
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;
148218

149219
/**
150220
* Basic options for Places JS.
221+
* ```javascript
222+
* new JawgPlaces({
223+
* accessToken: '<Access-Token>',
224+
* input: '#my-input'
225+
* })
226+
* ```
151227
*/
152228
interface JawgPlacesOptions {
153229
/**
@@ -184,14 +260,14 @@ declare namespace JawgPlaces {
184260
* This option work only when `searchOnTyping=true`.
185261
* Default value is `0`.
186262
*/
187-
minLength?: number;
263+
minLength?: number;
188264
/**
189265
* Set the number of milliseconds to wait before a search validation.
190266
* If you press `Enter` the search will be immediately validated.
191267
* This option work only when `searchOnTyping=true`.
192268
* Default value is `350`.
193269
*/
194-
debounceDelay?: number;
270+
debounceDelay?: number;
195271
/**
196272
* Filter the kind of place you want to find. Layers can be static or dynamic with the function.
197273
*/
@@ -201,7 +277,7 @@ declare namespace JawgPlaces {
201277
*/
202278
sources?: Source[] | Source | (() => Source[]) | (() => Source);
203279
/**
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}
205281
*/
206282
focusPoint?: LatLon | (() => LatLon);
207283
/**
@@ -228,7 +304,7 @@ declare namespace JawgPlaces {
228304
reverse?: ReverseOptions;
229305
/**
230306
* 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
232308
*/
233309
onFeatures?: (features: Feature[]) => void;
234310
/**
@@ -237,7 +313,7 @@ declare namespace JawgPlaces {
237313
onClose?: () => void;
238314
/**
239315
* 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
241317
*/
242318
onClick?: (feature: Feature) => void;
243319
/**
@@ -434,13 +510,13 @@ declare namespace JawgPlaces {
434510
* This is the function used by MapLibre and Mapbox when you add a
435511
* [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).
436512
* 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
439515
*/
440516
onAdd(map: maplibregl.Map | mapboxgl.Map): HTMLElement;
441517
/**
442518
* 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/)
444520
* @returns itself
445521
*/
446522
attachMap(map: maplibregl.Map | mapboxgl.Map): MapLibre;
@@ -454,6 +530,9 @@ declare namespace JawgPlaces {
454530
* This class will help you to add or use search bar for geocoding with a Mapbox GL JS map.
455531
*/
456532
class Mapbox extends MapLibre {
533+
/**
534+
* @inheritdoc
535+
*/
457536
attachMap(map: maplibregl.Map | mapboxgl.Map): Mapbox;
458537
}
459538

@@ -463,10 +542,9 @@ declare namespace JawgPlaces {
463542
class Leaflet extends AbstractPlaces {
464543
constructor(options: JawgPlacesLeafletOptions);
465544
/**
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).
467546
* 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)
470548
*/
471549
onAdd(map: L.Map): void;
472550
/**
@@ -475,12 +553,12 @@ declare namespace JawgPlaces {
475553
getPosition(): string;
476554
/**
477555
* 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)
479557
*/
480558
addTo(map: L.Map): void;
481559
/**
482560
* 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)
484562
* @returns itself
485563
*/
486564
attachMap(map: L.Map): Leaflet;

typedoc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
"readme": "none",
55
"gaID": "UA-148785463-1",
66
"gitRevision": "main",
7-
"githubPages": true,
7+
"githubPages": true
88
}

0 commit comments

Comments
 (0)