Skip to content

Commit

Permalink
feat(JawgPlaces): add support Place Details and fix some typo
Browse files Browse the repository at this point in the history
  • Loading branch information
Joxit committed Dec 18, 2024
1 parent 1f7809f commit b9bce88
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 40 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jawg/types",
"version": "1.1.0",
"version": "1.2.0",
"description": "Shared TypeScript definitions for Jawg Maps projects",
"types": "./index.d.ts",
"type": "module",
Expand Down
91 changes: 52 additions & 39 deletions src/places-js.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ declare namespace JawgPlaces {
}

/**
* Option to activate reverse geocoding withing the input.
* Option to activate reverse geocoding within the input.
* You can paste coordinates in the form {lat}/{lon} in the input.
* The separation can be either `/` (slash), `,` (comma) or ` ` (space).
* ```javascript
Expand Down Expand Up @@ -131,19 +131,19 @@ declare namespace JawgPlaces {
/**
* Add a restriction by alpha-2 or alpha-3 ISO-3166 country code. Countries can be static or dynamic with the function.
*/
countries: string[] | string | (() => string[]) | (() => string);
countries?: string[] | string | (() => string[]) | (() => string);
/**
* Search within a circular region. Circle can be static or dynamic with the function.
*/
circle: CircleOptions | (() => CircleOptions);
circle?: CircleOptions | (() => CircleOptions);
/**
* Add a restriction by GIDs. GIDs can be static or dynamic with the function.
*/
gids: string[] | string | (() => string[]) | (() => string);
gids?: string[] | string | (() => string[]) | (() => string);
/**
* Search within a rectangular region. Rectangle can be static or dynamic with the function.
*/
rectangle: RectangleOptions | (() => RectangleOptions);
rectangle?: RectangleOptions | (() => RectangleOptions);
}

/**
Expand All @@ -162,15 +162,40 @@ declare namespace JawgPlaces {
/**
* Add a priorities by alpha-2 or alpha-3 ISO-3166 country code. Countries can be static or dynamic with the function.
*/
countries: string[] | string | (() => string[]) | (() => string);
countries?: string[] | string | (() => string[]) | (() => string);
/**
* Sort results in part by their proximity to the given coordinate. Coordinates can be static or dynamic with the function.
*/
point?: LatLon | (() => LatLon);
/**
* Add a priorities by Jawg GIDs. GIDs can be static or dynamic with the function.
*/
gids: string[] | string | (() => string[]) | (() => string);
gids?: string[] | string | (() => string[]) | (() => string);
}

type GeometriesOptions = 'point' | 'source';

/**
* Option to activate Place Details within the input.
* You can paste one or many GIDs in the input.
* ```javascript
* new JawgPlaces({
* place: {
* enabled: true,
* geometries: 'source'
* }
* })
* ```
*/
interface PlaceOptions {
/**
* Activate the place endpoint.
*/
enabled: boolean;
/**
* Set the type of return from Places Details API, either a point or the source geometry.
*/
geometries?: GeometriesOptions | (() => GeometriesOptions);
}

/**
Expand Down Expand Up @@ -280,10 +305,15 @@ declare namespace JawgPlaces {
* See {@link FocusOptions.point}
*/
focusPoint?: LatLon | (() => LatLon);
/** {@inheritDoc FocusOptions} */
focus?: FocusOptions;
/** {@inheritDoc BoudaryOptions} */
boundary?: BoudaryOptions;
/**
* Set of options when you are looking for places in a particular region.
* {@inheritDoc PlaceOptions}
* @defaultValue false
*/
boundary?: BoudaryOptions;
place?: PlaceOptions | boolean;
/**
* Show icon at the left each results.
*/
Expand All @@ -297,11 +327,14 @@ declare namespace JawgPlaces {
*/
size?: number;
/**
* Option to activate reverse geocoding withing the input.
* You can paste coordinates in the form {lat}/{lon} in the input.
* The separation can be either `/` (slash), `,` (comma) or ` ` (space).
* {@inheritDoc ReverseOptions}
* @defaultValue false
*/
reverse?: ReverseOptions | boolean;
/**
* Set a custom message when no results are found. This can be disabled.
*/
reverse?: ReverseOptions;
noResultsMessage?: string | false;
/**
* Callback triggered when Jawg Places API returns without error.
* @param features The list of features returned by Jawg Places API
Expand Down Expand Up @@ -432,22 +465,12 @@ declare namespace JawgPlaces {
* Class to add to the input when it's generated by the library.
*/
inputClasses?: string | string[];
/**
* Option to show administrative area when available.
*/
/** {@inheritDoc AdminAreaOptions} */
adminArea?: AdminAreaOptions;
/**
* Option to configure result markers on the map.
*/
/** {@inheritDoc MapGLMarkerOptions} */
marker?: MapGLMarkerOptions | boolean | 'all';
/**
* Option to configure transition on result selection.
*/
/** {@inheritDoc MapGLTransitionOptions} */
transition?: MapGLTransitionOptions;
/**
* Set a custom message when no results are found. This can be disabled.
*/
noResultsMessage?: string | false;
}

/**
Expand All @@ -468,22 +491,12 @@ declare namespace JawgPlaces {
* Class to add to the input when it's generated by the library.
*/
inputClasses?: string | string[];
/**
* Option to show administrative area when available.
*/
/** {@inheritDoc AdminAreaOptions} */
adminArea?: AdminAreaOptions;
/**
* Option to configure result markers on the map.
*/
/** {@inheritDoc LeafletMarkerOptions} */
marker?: LeafletMarkerOptions | boolean | 'all';
/**
* Option to configure transition on result selection.
*/
/** {@inheritDoc LeafletTransitionOptions} */
transition?: LeafletTransitionOptions;
/**
* Set a custom message when no results are found. This can be disabled.
*/
noResultsMessage?: string | false;
/**
* Position of the input on the map.
*/
Expand Down

0 comments on commit b9bce88

Please sign in to comment.