mapricot 0.6.0 → 0.7.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 +8 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,6 +35,7 @@ Each method returns the API's JSON, typed, with the same field names as the [API
|
|
|
35
35
|
| `client.nearby(lat, lon, { category, radius, limit, lang })` | [`GET /places/v1/nearby`](https://mapricot.com/docs/places/#list-places-around-a-point) |
|
|
36
36
|
| `client.place(id, { lang })` | [`GET /places/v1/{id}`](https://mapricot.com/docs/places/#look-up-a-saved-place) |
|
|
37
37
|
| `client.route(waypoints, { mode, geometries })` | [`POST /routing/v1/route`](https://mapricot.com/docs/routing/#get-a-route) |
|
|
38
|
+
| `client.isochrone(location, minutes, { mode })` | [`POST /routing/v1/isochrone`](https://mapricot.com/docs/routing/#get-an-isochrone) |
|
|
38
39
|
| `client.ip(address)` | [`GET /ip-geolocation/v1/{ip}`](https://mapricot.com/docs/ip-geolocation/#look-up-an-address) |
|
|
39
40
|
| `client.account()` | `GET /account`, which checks a key and is never billed |
|
|
40
41
|
|
|
@@ -56,6 +57,13 @@ controller.abort();
|
|
|
56
57
|
|
|
57
58
|
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
59
|
|
|
60
|
+
An isochrone is a GeoJSON `FeatureCollection` with one polygon per time, largest first, so a map that draws them in order shows the smaller ones on top:
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
const area = await client.isochrone({ lat: 45.5189, lon: -122.6793 }, [5, 10], { mode: "walk" });
|
|
64
|
+
map.addSource("reach", { type: "geojson", data: area });
|
|
65
|
+
```
|
|
66
|
+
|
|
59
67
|
If your app shows results, show the credits in each response's `attribution`.
|
|
60
68
|
|
|
61
69
|
## Errors and retries
|
package/dist/index.d.ts
CHANGED
|
@@ -55,6 +55,26 @@ export interface Routes {
|
|
|
55
55
|
routes: Route[];
|
|
56
56
|
attribution?: Attribution[];
|
|
57
57
|
}
|
|
58
|
+
export interface Isochrone {
|
|
59
|
+
type: "Feature";
|
|
60
|
+
properties: {
|
|
61
|
+
minutes: number;
|
|
62
|
+
};
|
|
63
|
+
/** [longitude, latitude] rings, as GeoJSON. */
|
|
64
|
+
geometry: {
|
|
65
|
+
type: "Polygon";
|
|
66
|
+
coordinates: [number, number][][];
|
|
67
|
+
} | {
|
|
68
|
+
type: "MultiPolygon";
|
|
69
|
+
coordinates: [number, number][][][];
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export interface Isochrones {
|
|
73
|
+
type: "FeatureCollection";
|
|
74
|
+
/** One area per time, largest first. Empty when there is no road near the location. */
|
|
75
|
+
features: Isochrone[];
|
|
76
|
+
attribution?: Attribution[];
|
|
77
|
+
}
|
|
58
78
|
export interface IpLocation {
|
|
59
79
|
ip: string;
|
|
60
80
|
found: boolean;
|
|
@@ -134,6 +154,10 @@ export declare class Mapricot {
|
|
|
134
154
|
mode?: "drive" | "walk" | "bicycle";
|
|
135
155
|
geometries?: "polyline" | "polyline6" | "geojson";
|
|
136
156
|
}): Promise<Routes>;
|
|
157
|
+
/** The areas reachable from a location within 1 to 4 times, each 1 to 60 minutes. */
|
|
158
|
+
isochrone(location: Point, minutes: number[], { signal, ...options }?: RequestOptions & {
|
|
159
|
+
mode?: "drive" | "walk" | "bicycle";
|
|
160
|
+
}): Promise<Isochrones>;
|
|
137
161
|
/** Approximate location of a public IP address. */
|
|
138
162
|
ip(address: string, { signal }?: RequestOptions): Promise<IpLocation>;
|
|
139
163
|
/** The key's account. Not billed, so it checks a key for free. */
|
package/dist/index.js
CHANGED
|
@@ -58,6 +58,10 @@ export class Mapricot {
|
|
|
58
58
|
route(waypoints, { signal, ...options } = {}) {
|
|
59
59
|
return __classPrivateFieldGet(this, _Mapricot_instances, "m", _Mapricot_request).call(this, "POST", "/routing/v1/route", {}, signal, { waypoints, ...options });
|
|
60
60
|
}
|
|
61
|
+
/** The areas reachable from a location within 1 to 4 times, each 1 to 60 minutes. */
|
|
62
|
+
isochrone(location, minutes, { signal, ...options } = {}) {
|
|
63
|
+
return __classPrivateFieldGet(this, _Mapricot_instances, "m", _Mapricot_request).call(this, "POST", "/routing/v1/isochrone", {}, signal, { location, minutes, ...options });
|
|
64
|
+
}
|
|
61
65
|
/** Approximate location of a public IP address. */
|
|
62
66
|
ip(address, { signal } = {}) {
|
|
63
67
|
return __classPrivateFieldGet(this, _Mapricot_instances, "m", _Mapricot_request).call(this, "GET", `/ip-geolocation/v1/${encodeURIComponent(address)}`, {}, signal);
|