mapricot 0.12.0 → 0.13.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
@@ -25,7 +25,7 @@ In a web page, use a browser key, which works only from the origins you allow, a
25
25
 
26
26
  ## Methods
27
27
 
28
- Methods are grouped by product, the same way as the API's paths. Each returns the API's JSON, typed, with the same field names as the [API reference](https://mapricot.com/api-reference/).
28
+ Methods are grouped by product, the same way as the API's paths. Each returns the API's JSON, typed, with the same field names as the [API reference](https://mapricot.com/docs/api-reference/).
29
29
 
30
30
  | Method | Endpoint |
31
31
  | --- | --- |
@@ -35,9 +35,9 @@ Methods are grouped by product, the same way as the API's paths. Each returns th
35
35
  | `client.geocoding.reverse(lat, lon, { limit, lang })` | [`GET /geocoding/v1/reverse`](https://mapricot.com/docs/geocoding/#find-the-address-at-a-point) |
36
36
  | `client.places.nearby(lat, lon, { category, radius, limit, lang })` | [`GET /places/v1/nearby`](https://mapricot.com/docs/places/#list-places-around-a-point) |
37
37
  | `client.places.get(id, { lang })` | [`GET /places/v1/{id}`](https://mapricot.com/docs/places/#look-up-a-saved-place) |
38
- | `client.routing.route(waypoints, { mode, geometries, steps, lang })` | [`POST /routing/v1/route`](https://mapricot.com/docs/routing/#get-a-route) |
39
- | `client.routing.optimize(waypoints, { mode, geometries, steps, lang })` | [`POST /routing/v1/optimize`](https://mapricot.com/docs/routing/#optimize-the-order-of-stops) |
40
- | `client.routing.isochrone(location, minutes, { mode })` | [`POST /routing/v1/isochrone`](https://mapricot.com/docs/routing/#get-an-isochrone) |
38
+ | `client.routing.route(waypoints, { mode, geometries, steps, lang, costing })` | [`POST /routing/v1/route`](https://mapricot.com/docs/routing/#get-a-route) |
39
+ | `client.routing.optimize(waypoints, { mode, geometries, steps, lang, costing })` | [`POST /routing/v1/optimize`](https://mapricot.com/docs/routing/#optimize-the-order-of-stops) |
40
+ | `client.routing.isochrone(location, minutes, { mode, costing })` | [`POST /routing/v1/isochrone`](https://mapricot.com/docs/routing/#get-an-isochrone) |
41
41
  | `client.ipGeolocation.lookup(ip)` | [`GET /ip-geolocation/v1/{ip}`](https://mapricot.com/docs/ip-geolocation/#look-up-an-address) |
42
42
  | `client.account()` | `GET /account`, which checks a key and is never billed |
43
43
 
@@ -77,6 +77,8 @@ map.addSource("reach", { type: "geojson", data: area });
77
77
 
78
78
  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"`.
79
79
 
80
+ `costing` changes how a route, optimized route, or isochrone picks its roads, with Valhalla's [costing options](https://mapricot.com/docs/routing/#costing-options) for the mode, such as `{ useTolls: 0, useHighways: 0 }` to drive avoiding tolls and highways where it can.
81
+
80
82
  If your app shows results, show the credits in each response's `attribution`.
81
83
 
82
84
  ## Errors and retries
@@ -94,11 +96,11 @@ try {
94
96
  }
95
97
  ```
96
98
 
97
- The client retries `503` responses and `429 concurrency_exceeded`, up to twice, waiting longer each time. Errors aren't billed. Set `maxRetries` and `timeout` (milliseconds) in the constructor's options to change this. The [API reference](https://mapricot.com/api-reference/#errors) lists every status.
99
+ The client retries `503` responses and `429 concurrency_exceeded`, up to twice, waiting longer each time. Errors aren't billed. Set `maxRetries` and `timeout` (milliseconds) in the constructor's options to change this. The [API reference](https://mapricot.com/docs/api-reference/#errors) lists every status.
98
100
 
99
101
  ## Links
100
102
 
101
103
  - [Mapricot](https://mapricot.com/)
102
104
  - [Node.js docs](https://mapricot.com/docs/node/)
103
- - [API reference](https://mapricot.com/api-reference/)
105
+ - [API reference](https://mapricot.com/docs/api-reference/)
104
106
  - [Pricing](https://mapricot.com/pricing/)
package/dist/index.d.ts CHANGED
@@ -60,6 +60,8 @@ export interface PlaceResult {
60
60
  result: Place;
61
61
  attribution: Attribution[];
62
62
  }
63
+ /** Valhalla's costing options for the mode, named in camelCase, such as `{ useTolls: 0 }`. See https://mapricot.com/docs/routing/#costing-options. */
64
+ export type Costing = Record<string, number | boolean | string>;
63
65
  export interface Leg {
64
66
  distanceMeters: number;
65
67
  durationSeconds: number;
@@ -202,6 +204,7 @@ export declare class Mapricot {
202
204
  geometries?: "polyline" | "polyline6" | "geojson";
203
205
  steps?: boolean;
204
206
  lang?: string;
207
+ costing?: Costing;
205
208
  }) => Promise<Routes>;
206
209
  /** Find a fast route through 2 to 20 waypoints, keeping the first and last in place and reordering the rest. */
207
210
  optimize: (waypoints: Point[], { signal, ...options }?: RequestOptions & {
@@ -209,10 +212,12 @@ export declare class Mapricot {
209
212
  geometries?: "polyline" | "polyline6" | "geojson";
210
213
  steps?: boolean;
211
214
  lang?: string;
215
+ costing?: Costing;
212
216
  }) => Promise<Routes>;
213
217
  /** The areas reachable from a location within 1 to 4 times, each 1 to 60 minutes. */
214
218
  isochrone: (location: Point, minutes: number[], { signal, ...options }?: RequestOptions & {
215
219
  mode?: "drive" | "walk" | "bicycle";
220
+ costing?: Costing;
216
221
  }) => Promise<Isochrones>;
217
222
  };
218
223
  readonly ipGeolocation: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mapricot",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Official client for the Mapricot API: geocoding, places, routing, and IP geolocation.",
5
5
  "keywords": [
6
6
  "geocoding",