mapricot 0.4.0 → 0.6.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 +9 -9
- package/dist/index.d.ts +10 -2
- package/dist/index.js +8 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,14 +29,14 @@ Each method returns the API's JSON, typed, with the same field names as the [API
|
|
|
29
29
|
|
|
30
30
|
| Method | Endpoint |
|
|
31
31
|
| --- | --- |
|
|
32
|
-
| `client.search(q, { focus, country, limit, lang })` | [`GET /v1/search`](https://mapricot.com/docs/geocoding/#find-an-address) |
|
|
33
|
-
| `client.autocomplete(q, { focus, country, limit, lang })` | [`GET /v1/autocomplete`](https://mapricot.com/docs/
|
|
34
|
-
| `client.reverse(lat, lon, { limit, lang })` | [`GET /v1/reverse`](https://mapricot.com/docs/geocoding/#find-the-address-at-a-point) |
|
|
35
|
-
| `client.nearby(lat, lon, { category, radius, limit, lang })` | [`GET /v1/nearby`](https://mapricot.com/docs/places/#list-places-around-a-point) |
|
|
36
|
-
| `client.place(id, { lang })` | [`GET /v1/
|
|
37
|
-
| `client.route(waypoints, { mode })` | [`POST /v1/route`](https://mapricot.com/docs/routing/#get-a-route) |
|
|
38
|
-
| `client.ip(address)` | [`GET /v1/
|
|
39
|
-
| `client.account()` | `GET /
|
|
32
|
+
| `client.search(q, { focus, country, limit, lang })` | [`GET /geocoding/v1/search`](https://mapricot.com/docs/geocoding/#find-an-address) |
|
|
33
|
+
| `client.autocomplete(q, { focus, country, limit, lang })` | [`GET /geocoding/v1/autocomplete`](https://mapricot.com/docs/geocoding/#suggest-as-people-type) |
|
|
34
|
+
| `client.reverse(lat, lon, { limit, lang })` | [`GET /geocoding/v1/reverse`](https://mapricot.com/docs/geocoding/#find-the-address-at-a-point) |
|
|
35
|
+
| `client.nearby(lat, lon, { category, radius, limit, lang })` | [`GET /places/v1/nearby`](https://mapricot.com/docs/places/#list-places-around-a-point) |
|
|
36
|
+
| `client.place(id, { lang })` | [`GET /places/v1/{id}`](https://mapricot.com/docs/places/#look-up-a-saved-place) |
|
|
37
|
+
| `client.route(waypoints, { mode, geometries })` | [`POST /routing/v1/route`](https://mapricot.com/docs/routing/#get-a-route) |
|
|
38
|
+
| `client.ip(address)` | [`GET /ip-geolocation/v1/{ip}`](https://mapricot.com/docs/ip-geolocation/#look-up-an-address) |
|
|
39
|
+
| `client.account()` | `GET /account`, which checks a key and is never billed |
|
|
40
40
|
|
|
41
41
|
`focus` and each waypoint are `{ lat, lon }`. `country` and `category` take an array or a comma-separated string.
|
|
42
42
|
|
|
@@ -54,7 +54,7 @@ const request = client.autocomplete("1005 W Burn", { signal: controller.signal }
|
|
|
54
54
|
controller.abort();
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
A route's `polyline`
|
|
57
|
+
A route's path comes as an encoded `polyline` with five decimal places, which polyline decoders assume. Pass `geometries: "geojson"` to get it as a GeoJSON `LineString` in `geometry` instead, which maps draw without decoding, or `geometries: "polyline6"` for six decimal places.
|
|
58
58
|
|
|
59
59
|
If your app shows results, show the credits in each response's `attribution`.
|
|
60
60
|
|
package/dist/index.d.ts
CHANGED
|
@@ -40,10 +40,17 @@ export interface Leg {
|
|
|
40
40
|
export interface Route {
|
|
41
41
|
distanceMeters: number;
|
|
42
42
|
durationSeconds: number;
|
|
43
|
-
/** Encoded polyline with
|
|
44
|
-
polyline
|
|
43
|
+
/** Encoded polyline, with five decimal places unless `geometries` was `polyline6`. Absent for `geojson`. */
|
|
44
|
+
polyline?: string;
|
|
45
|
+
/** The path as GeoJSON, when `geometries` was `geojson`. */
|
|
46
|
+
geometry?: LineString;
|
|
45
47
|
legs: Leg[];
|
|
46
48
|
}
|
|
49
|
+
export interface LineString {
|
|
50
|
+
type: "LineString";
|
|
51
|
+
/** [longitude, latitude] pairs. */
|
|
52
|
+
coordinates: [number, number][];
|
|
53
|
+
}
|
|
47
54
|
export interface Routes {
|
|
48
55
|
routes: Route[];
|
|
49
56
|
attribution?: Attribution[];
|
|
@@ -125,6 +132,7 @@ export declare class Mapricot {
|
|
|
125
132
|
/** Find a route through 2 to 20 waypoints. */
|
|
126
133
|
route(waypoints: Point[], { signal, ...options }?: RequestOptions & {
|
|
127
134
|
mode?: "drive" | "walk" | "bicycle";
|
|
135
|
+
geometries?: "polyline" | "polyline6" | "geojson";
|
|
128
136
|
}): Promise<Routes>;
|
|
129
137
|
/** Approximate location of a public IP address. */
|
|
130
138
|
ip(address: string, { signal }?: RequestOptions): Promise<IpLocation>;
|
package/dist/index.js
CHANGED
|
@@ -36,35 +36,35 @@ export class Mapricot {
|
|
|
36
36
|
}
|
|
37
37
|
/** Find addresses and places matching free text. */
|
|
38
38
|
search(q, { signal, ...options } = {}) {
|
|
39
|
-
return __classPrivateFieldGet(this, _Mapricot_instances, "m", _Mapricot_request).call(this, "GET", "/v1/search", { q, ...options }, signal);
|
|
39
|
+
return __classPrivateFieldGet(this, _Mapricot_instances, "m", _Mapricot_request).call(this, "GET", "/geocoding/v1/search", { q, ...options }, signal);
|
|
40
40
|
}
|
|
41
41
|
/** Suggest addresses and places as someone types. */
|
|
42
42
|
autocomplete(q, { signal, ...options } = {}) {
|
|
43
|
-
return __classPrivateFieldGet(this, _Mapricot_instances, "m", _Mapricot_request).call(this, "GET", "/v1/autocomplete", { q, ...options }, signal);
|
|
43
|
+
return __classPrivateFieldGet(this, _Mapricot_instances, "m", _Mapricot_request).call(this, "GET", "/geocoding/v1/autocomplete", { q, ...options }, signal);
|
|
44
44
|
}
|
|
45
45
|
/** Find the address nearest a coordinate, or the area around it. */
|
|
46
46
|
reverse(lat, lon, { signal, ...options } = {}) {
|
|
47
|
-
return __classPrivateFieldGet(this, _Mapricot_instances, "m", _Mapricot_request).call(this, "GET", "/v1/reverse", { lat, lon, ...options }, signal);
|
|
47
|
+
return __classPrivateFieldGet(this, _Mapricot_instances, "m", _Mapricot_request).call(this, "GET", "/geocoding/v1/reverse", { lat, lon, ...options }, signal);
|
|
48
48
|
}
|
|
49
49
|
/** List places around a coordinate, optionally by category. */
|
|
50
50
|
nearby(lat, lon, { signal, ...options } = {}) {
|
|
51
|
-
return __classPrivateFieldGet(this, _Mapricot_instances, "m", _Mapricot_request).call(this, "GET", "/v1/nearby", { lat, lon, ...options }, signal);
|
|
51
|
+
return __classPrivateFieldGet(this, _Mapricot_instances, "m", _Mapricot_request).call(this, "GET", "/places/v1/nearby", { lat, lon, ...options }, signal);
|
|
52
52
|
}
|
|
53
53
|
/** Look up one place by its Mapricot ID. */
|
|
54
54
|
place(id, { signal, ...options } = {}) {
|
|
55
|
-
return __classPrivateFieldGet(this, _Mapricot_instances, "m", _Mapricot_request).call(this, "GET", `/v1
|
|
55
|
+
return __classPrivateFieldGet(this, _Mapricot_instances, "m", _Mapricot_request).call(this, "GET", `/places/v1/${encodeURIComponent(id)}`, options, signal);
|
|
56
56
|
}
|
|
57
57
|
/** Find a route through 2 to 20 waypoints. */
|
|
58
58
|
route(waypoints, { signal, ...options } = {}) {
|
|
59
|
-
return __classPrivateFieldGet(this, _Mapricot_instances, "m", _Mapricot_request).call(this, "POST", "/v1/route", {}, signal, { waypoints, ...options });
|
|
59
|
+
return __classPrivateFieldGet(this, _Mapricot_instances, "m", _Mapricot_request).call(this, "POST", "/routing/v1/route", {}, signal, { waypoints, ...options });
|
|
60
60
|
}
|
|
61
61
|
/** Approximate location of a public IP address. */
|
|
62
62
|
ip(address, { signal } = {}) {
|
|
63
|
-
return __classPrivateFieldGet(this, _Mapricot_instances, "m", _Mapricot_request).call(this, "GET", `/v1
|
|
63
|
+
return __classPrivateFieldGet(this, _Mapricot_instances, "m", _Mapricot_request).call(this, "GET", `/ip-geolocation/v1/${encodeURIComponent(address)}`, {}, signal);
|
|
64
64
|
}
|
|
65
65
|
/** The key's account. Not billed, so it checks a key for free. */
|
|
66
66
|
account({ signal } = {}) {
|
|
67
|
-
return __classPrivateFieldGet(this, _Mapricot_instances, "m", _Mapricot_request).call(this, "GET", "/
|
|
67
|
+
return __classPrivateFieldGet(this, _Mapricot_instances, "m", _Mapricot_request).call(this, "GET", "/account", {}, signal);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
_Mapricot_apiKey = new WeakMap(), _Mapricot_baseUrl = new WeakMap(), _Mapricot_timeout = new WeakMap(), _Mapricot_maxRetries = new WeakMap(), _Mapricot_instances = new WeakSet(), _Mapricot_request = async function _Mapricot_request(method, path, params, signal, body) {
|