mapricot 0.14.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 +8 -2
- package/dist/index.d.ts +16 -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) |
|
|
@@ -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 }]);
|
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. */
|
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)]))),
|