mapricot 0.8.0 → 0.9.0

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/README.md CHANGED
@@ -34,7 +34,7 @@ Methods are grouped by product, the same way as the API's paths. Each returns th
34
34
  | `client.geocoding.reverse(lat, lon, { limit, lang })` | [`GET /geocoding/v1/reverse`](https://mapricot.com/docs/geocoding/#find-the-address-at-a-point) |
35
35
  | `client.places.nearby(lat, lon, { category, radius, limit, lang })` | [`GET /places/v1/nearby`](https://mapricot.com/docs/places/#list-places-around-a-point) |
36
36
  | `client.places.get(id, { lang })` | [`GET /places/v1/{id}`](https://mapricot.com/docs/places/#look-up-a-saved-place) |
37
- | `client.routing.route(waypoints, { mode, geometries })` | [`POST /routing/v1/route`](https://mapricot.com/docs/routing/#get-a-route) |
37
+ | `client.routing.route(waypoints, { mode, geometries, steps, lang })` | [`POST /routing/v1/route`](https://mapricot.com/docs/routing/#get-a-route) |
38
38
  | `client.routing.isochrone(location, minutes, { mode })` | [`POST /routing/v1/isochrone`](https://mapricot.com/docs/routing/#get-an-isochrone) |
39
39
  | `client.ipGeolocation.lookup(ip)` | [`GET /ip-geolocation/v1/{ip}`](https://mapricot.com/docs/ip-geolocation/#look-up-an-address) |
40
40
  | `client.account()` | `GET /account`, which checks a key and is never billed |
@@ -64,6 +64,8 @@ const area = await client.routing.isochrone({ lat: 45.5189, lon: -122.6793 }, [5
64
64
  map.addSource("reach", { type: "geojson", data: area });
65
65
  ```
66
66
 
67
+ Pass `steps: true` and each leg's `steps` has its turn-by-turn directions: an `instruction`, its distance and time, and its `lat` and `lon`. They're in English unless you pass `lang`, such as `lang: "fr"`.
68
+
67
69
  If your app shows results, show the credits in each response's `attribution`.
68
70
 
69
71
  ## Errors and retries
package/dist/index.d.ts CHANGED
@@ -36,6 +36,17 @@ export interface PlaceResult {
36
36
  export interface Leg {
37
37
  distanceMeters: number;
38
38
  durationSeconds: number;
39
+ /** Turn-by-turn directions, in order, when the route was asked for with `steps: true`. The last step is the arrival. */
40
+ steps?: Step[];
41
+ }
42
+ /** One maneuver, and the stretch from it to the next. */
43
+ export interface Step {
44
+ instruction: string;
45
+ distanceMeters: number;
46
+ durationSeconds: number;
47
+ /** Where the maneuver is, on the route's path. */
48
+ lat: number;
49
+ lon: number;
39
50
  }
40
51
  export interface Route {
41
52
  distanceMeters: number;
@@ -158,6 +169,8 @@ export declare class Mapricot {
158
169
  route: (waypoints: Point[], { signal, ...options }?: RequestOptions & {
159
170
  mode?: "drive" | "walk" | "bicycle";
160
171
  geometries?: "polyline" | "polyline6" | "geojson";
172
+ steps?: boolean;
173
+ lang?: string;
161
174
  }) => Promise<Routes>;
162
175
  /** The areas reachable from a location within 1 to 4 times, each 1 to 60 minutes. */
163
176
  isochrone: (location: Point, minutes: number[], { signal, ...options }?: RequestOptions & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mapricot",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Official client for the Mapricot API: geocoding, places, routing, and IP geolocation.",
5
5
  "keywords": [
6
6
  "geocoding",