mapricot 0.13.0 → 0.15.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 +11 -3
- package/dist/index.d.ts +17 -5
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ Methods are grouped by product, the same way as the API's paths. Each returns th
|
|
|
29
29
|
|
|
30
30
|
| Method | Endpoint |
|
|
31
31
|
| --- | --- |
|
|
32
|
-
| `client.geocoding.search(q, { focus, country, limit, lang })` | [`GET /geocoding/v1/search`](https://mapricot.com/docs/geocoding/#find-an-address) |
|
|
32
|
+
| `client.geocoding.search(q or { address, locality, county, region, postalCode }, { focus, country, limit, lang })` | [`GET /geocoding/v1/search`](https://mapricot.com/docs/geocoding/#find-an-address) |
|
|
33
33
|
| `client.geocoding.searchBatch(queries)` | [`POST /geocoding/v1/search/batch`](https://mapricot.com/docs/geocoding/#search-a-list-of-addresses) |
|
|
34
34
|
| `client.geocoding.autocomplete(q, { focus, country, limit, lang })` | [`GET /geocoding/v1/autocomplete`](https://mapricot.com/docs/geocoding/#suggest-as-people-type) |
|
|
35
35
|
| `client.geocoding.reverse(lat, lon, { limit, lang })` | [`GET /geocoding/v1/reverse`](https://mapricot.com/docs/geocoding/#find-the-address-at-a-point) |
|
|
@@ -37,7 +37,7 @@ Methods are grouped by product, the same way as the API's paths. Each returns th
|
|
|
37
37
|
| `client.places.get(id, { lang })` | [`GET /places/v1/{id}`](https://mapricot.com/docs/places/#look-up-a-saved-place) |
|
|
38
38
|
| `client.routing.route(waypoints, { mode, geometries, steps, lang, costing })` | [`POST /routing/v1/route`](https://mapricot.com/docs/routing/#get-a-route) |
|
|
39
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) |
|
|
40
|
+
| `client.routing.isochrone(location, minutes, { mode, costing, generalize })` | [`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
|
|
|
@@ -49,7 +49,13 @@ const { routes } = await client.routing.route([{ lat: 45.5189, lon: -122.6793 },
|
|
|
49
49
|
console.log(routes[0].durationSeconds);
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
When you already have an address in parts, such as a spreadsheet's columns, pass them in place of the text. Search ignores a blank part:
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
const { results } = await client.geocoding.search({ address: "10 Downing Street", locality: "London", postalCode: "SW1A 2AA" }, { country: "GB" });
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
`searchBatch` runs up to 100 searches in one request. Each query is an object of `search`'s parameters, with `q` or the address parts, and `responses` answers them in the same order, each with `results` and `attribution`, or an `error` with the `code` and `message` that search would get, without rejecting. Each completed search is billed as one request; errors aren't.
|
|
53
59
|
|
|
54
60
|
```js
|
|
55
61
|
const { responses } = await client.geocoding.searchBatch([{ q: "128 SW 3rd Ave, Portland", limit: 1 }, { q: "10 Downing Street, London", limit: 1 }]);
|
|
@@ -75,6 +81,8 @@ const area = await client.routing.isochrone({ lat: 45.5189, lon: -122.6793 }, [5
|
|
|
75
81
|
map.addSource("reach", { type: "geojson", data: area });
|
|
76
82
|
```
|
|
77
83
|
|
|
84
|
+
`generalize` smooths each outline to within that many meters, from 10 to 5000, so it has fewer points. The API picks it from the travel time when you leave it out. A long drive's outlines are detailed and large, and `generalize: 300` makes them much smaller while keeping their shape at city scale.
|
|
85
|
+
|
|
78
86
|
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
87
|
|
|
80
88
|
`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.
|
package/dist/index.d.ts
CHANGED
|
@@ -35,9 +35,20 @@ export interface Places {
|
|
|
35
35
|
results: Place[];
|
|
36
36
|
attribution: Attribution[];
|
|
37
37
|
}
|
|
38
|
-
/**
|
|
39
|
-
export interface
|
|
40
|
-
|
|
38
|
+
/** An address in parts, such as a spreadsheet's columns, which search takes in place of free text. */
|
|
39
|
+
export interface AddressParts {
|
|
40
|
+
/** The street line: house number, street, and any unit or building. */
|
|
41
|
+
address?: string;
|
|
42
|
+
/** The town or city. */
|
|
43
|
+
locality?: string;
|
|
44
|
+
county?: string;
|
|
45
|
+
/** The state, province, or region. */
|
|
46
|
+
region?: string;
|
|
47
|
+
postalCode?: string;
|
|
48
|
+
}
|
|
49
|
+
/** One search in a batch, with the same parameters as `geocoding.search`: `q`, or an address in parts. */
|
|
50
|
+
export interface SearchQuery extends AddressParts {
|
|
51
|
+
q?: string;
|
|
41
52
|
focus?: Point;
|
|
42
53
|
country?: string | string[];
|
|
43
54
|
limit?: number;
|
|
@@ -180,8 +191,8 @@ export declare class Mapricot {
|
|
|
180
191
|
#private;
|
|
181
192
|
constructor(options: ClientOptions);
|
|
182
193
|
readonly geocoding: {
|
|
183
|
-
/** Find addresses and places matching free text. */
|
|
184
|
-
search: (
|
|
194
|
+
/** Find addresses and places matching free text, or an address given in parts. */
|
|
195
|
+
search: (query: string | AddressParts, { signal, ...options }?: SearchOptions) => Promise<Places>;
|
|
185
196
|
/** Run up to 100 searches in one request. Each completed search is billed as one request. */
|
|
186
197
|
searchBatch: (queries: SearchQuery[], { signal }?: RequestOptions) => Promise<SearchBatch>;
|
|
187
198
|
/** Suggest addresses and places as someone types. */
|
|
@@ -218,6 +229,7 @@ export declare class Mapricot {
|
|
|
218
229
|
isochrone: (location: Point, minutes: number[], { signal, ...options }?: RequestOptions & {
|
|
219
230
|
mode?: "drive" | "walk" | "bicycle";
|
|
220
231
|
costing?: Costing;
|
|
232
|
+
generalize?: number;
|
|
221
233
|
}) => Promise<Isochrones>;
|
|
222
234
|
};
|
|
223
235
|
readonly ipGeolocation: {
|
package/dist/index.js
CHANGED
|
@@ -28,8 +28,8 @@ export class Mapricot {
|
|
|
28
28
|
_Mapricot_timeout.set(this, void 0);
|
|
29
29
|
_Mapricot_maxRetries.set(this, void 0);
|
|
30
30
|
this.geocoding = {
|
|
31
|
-
/** Find addresses and places matching free text. */
|
|
32
|
-
search: (
|
|
31
|
+
/** Find addresses and places matching free text, or an address given in parts. */
|
|
32
|
+
search: (query, { signal, ...options } = {}) => __classPrivateFieldGet(this, _Mapricot_instances, "m", _Mapricot_request).call(this, "GET", "/geocoding/v1/search", { ...(typeof query === "string" ? { q: query } : query), ...options }, signal),
|
|
33
33
|
/** Run up to 100 searches in one request. Each completed search is billed as one request. */
|
|
34
34
|
searchBatch: (queries, { signal } = {}) => __classPrivateFieldGet(this, _Mapricot_instances, "m", _Mapricot_request).call(this, "POST", "/geocoding/v1/search/batch", {}, signal, {
|
|
35
35
|
queries: queries.map((query) => Object.fromEntries(Object.entries(query).map(([name, value]) => [name, format(value)]))),
|