@esri/arcgis-rest-geocoding 4.0.0-beta.2 → 4.0.1
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 +1 -1
- package/dist/bundled/geocoding.esm.js +17 -12
- package/dist/bundled/geocoding.esm.js.map +1 -1
- package/dist/bundled/geocoding.esm.min.js +2 -2
- package/dist/bundled/geocoding.esm.min.js.map +1 -1
- package/dist/bundled/geocoding.umd.js +17 -12
- package/dist/bundled/geocoding.umd.js.map +1 -1
- package/dist/bundled/geocoding.umd.min.js +2 -2
- package/dist/bundled/geocoding.umd.min.js.map +1 -1
- package/dist/cjs/bulk.js +5 -4
- package/dist/cjs/bulk.js.map +1 -1
- package/dist/cjs/geocode.js +6 -4
- package/dist/cjs/geocode.js.map +1 -1
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/reverse.js +2 -1
- package/dist/cjs/reverse.js.map +1 -1
- package/dist/cjs/suggest.js +2 -1
- package/dist/cjs/suggest.js.map +1 -1
- package/dist/esm/bulk.d.ts +5 -4
- package/dist/esm/bulk.js +5 -4
- package/dist/esm/bulk.js.map +1 -1
- package/dist/esm/geocode.d.ts +6 -4
- package/dist/esm/geocode.js +6 -4
- package/dist/esm/geocode.js.map +1 -1
- package/dist/esm/package.json +3 -0
- package/dist/esm/reverse.d.ts +2 -1
- package/dist/esm/reverse.js +2 -1
- package/dist/esm/reverse.js.map +1 -1
- package/dist/esm/suggest.d.ts +2 -1
- package/dist/esm/suggest.js +2 -1
- package/dist/esm/suggest.js.map +1 -1
- package/package.json +14 -3
package/dist/esm/bulk.d.ts
CHANGED
|
@@ -32,21 +32,22 @@ export interface IBulkGeocodeResponse {
|
|
|
32
32
|
}>;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
+
* Used to geocode a [batch](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-geocode-addresses.htm) of addresses.
|
|
36
|
+
*
|
|
35
37
|
* ```js
|
|
36
38
|
* import { bulkGeocode } from '@esri/arcgis-rest-geocoding';
|
|
37
|
-
* import {
|
|
38
|
-
*
|
|
39
|
+
* import { ApplicationCredentialsManager } from '@esri/arcgis-rest-request';
|
|
40
|
+
*
|
|
39
41
|
* const addresses = [
|
|
40
42
|
* { "OBJECTID": 1, "SingleLine": "380 New York Street 92373" },
|
|
41
43
|
* { "OBJECTID": 2, "SingleLine": "1 World Way Los Angeles 90045" }
|
|
42
44
|
* ];
|
|
43
|
-
*
|
|
45
|
+
*
|
|
44
46
|
* bulkGeocode({ addresses, authentication: session })
|
|
45
47
|
* .then((response) => {
|
|
46
48
|
* response.locations[0].location; // => { x: -117, y: 34, spatialReference: { wkid: 4326 } }
|
|
47
49
|
* });
|
|
48
50
|
* ```
|
|
49
|
-
* Used to geocode a [batch](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-geocode-addresses.htm) of addresses.
|
|
50
51
|
*
|
|
51
52
|
* @param requestOptions - Request options to pass to the geocoder, including an array of addresses and authentication session.
|
|
52
53
|
* @returns A Promise that will resolve with the data from the response. The spatial reference will be added to address locations unless `rawResponse: true` was passed.
|
package/dist/esm/bulk.js
CHANGED
|
@@ -3,21 +3,22 @@
|
|
|
3
3
|
import { request, cleanUrl } from "@esri/arcgis-rest-request";
|
|
4
4
|
import { ARCGIS_ONLINE_BULK_GEOCODING_URL } from "./helpers.js";
|
|
5
5
|
/**
|
|
6
|
+
* Used to geocode a [batch](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-geocode-addresses.htm) of addresses.
|
|
7
|
+
*
|
|
6
8
|
* ```js
|
|
7
9
|
* import { bulkGeocode } from '@esri/arcgis-rest-geocoding';
|
|
8
|
-
* import {
|
|
9
|
-
*
|
|
10
|
+
* import { ApplicationCredentialsManager } from '@esri/arcgis-rest-request';
|
|
11
|
+
*
|
|
10
12
|
* const addresses = [
|
|
11
13
|
* { "OBJECTID": 1, "SingleLine": "380 New York Street 92373" },
|
|
12
14
|
* { "OBJECTID": 2, "SingleLine": "1 World Way Los Angeles 90045" }
|
|
13
15
|
* ];
|
|
14
|
-
*
|
|
16
|
+
*
|
|
15
17
|
* bulkGeocode({ addresses, authentication: session })
|
|
16
18
|
* .then((response) => {
|
|
17
19
|
* response.locations[0].location; // => { x: -117, y: 34, spatialReference: { wkid: 4326 } }
|
|
18
20
|
* });
|
|
19
21
|
* ```
|
|
20
|
-
* Used to geocode a [batch](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-geocode-addresses.htm) of addresses.
|
|
21
22
|
*
|
|
22
23
|
* @param requestOptions - Request options to pass to the geocoder, including an array of addresses and authentication session.
|
|
23
24
|
* @returns A Promise that will resolve with the data from the response. The spatial reference will be added to address locations unless `rawResponse: true` was passed.
|
package/dist/esm/bulk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bulk.js","sourceRoot":"","sources":["../../src/bulk.ts"],"names":[],"mappings":"AAAA;gBACgB;AAEhB,OAAO,
|
|
1
|
+
{"version":3,"file":"bulk.js","sourceRoot":"","sources":["../../src/bulk.ts"],"names":[],"mappings":"AAAA;gBACgB;AAEhB,OAAO,EACL,OAAO,EACP,QAAQ,EAGT,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,gCAAgC,EAEjC,MAAM,cAAc,CAAC;AAqCtB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,WAAW,CACzB,cAAmC,CAAC,kCAAkC;;IAEtE,MAAM,OAAO,mBACX,QAAQ,EAAE,gCAAgC,EAC1C,MAAM,EAAE,EAAE,IACP,cAAc,CAClB,CAAC;IAEF,OAAO,CAAC,MAAM,CAAC,SAAS,GAAG;QACzB,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;YAChD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;QACjC,CAAC,CAAC;KACH,CAAC;IAEF,sDAAsD;IACtD,IACE,CAAC,cAAc,CAAC,cAAc;QAC9B,OAAO,CAAC,QAAQ,KAAK,gCAAgC,EACrD;QACA,OAAO,OAAO,CAAC,MAAM,CACnB,iEAAiE,CAClE,CAAC;KACH;IAED,OAAO,OAAO,CACZ,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,EAChD,OAAO,CACR,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;QAClB,IAAI,OAAO,CAAC,WAAW,EAAE;YACvB,OAAO,QAAQ,CAAC;SACjB;QACD,MAAM,EAAE,GAAG,QAAQ,CAAC,gBAAgB,CAAC;QACrC,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,OAA6B;YAChE,IAAI,OAAO,CAAC,QAAQ,EAAE;gBACpB,OAAO,CAAC,QAAQ,CAAC,gBAAgB,GAAG,EAAE,CAAC;aACxC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n request,\n cleanUrl,\n ISpatialReference,\n IPoint\n} from \"@esri/arcgis-rest-request\";\n\nimport {\n ARCGIS_ONLINE_BULK_GEOCODING_URL,\n IEndpointOptions\n} from \"./helpers.js\";\n\n// It would be better if doc did not display these properties in alphabetical order\nexport interface IAddressBulk {\n /**\n * A unique id must be passed along for each individual address.\n */\n OBJECTID: number;\n address?: string;\n address2?: string;\n address3?: string;\n neighborhood?: string;\n city?: string;\n subregion?: string;\n /**\n * The World Geocoding Service considers US states regions.\n */\n region?: string;\n postal?: number;\n postalExt?: number;\n countryCode?: string;\n}\n\nexport interface IBulkGeocodeOptions extends IEndpointOptions {\n addresses: IAddressBulk[];\n}\n\nexport interface IBulkGeocodeResponse {\n spatialReference: ISpatialReference;\n locations: Array<{\n address: string;\n location?: IPoint; // candidates with a score of 0 wont include a location\n score: number;\n attributes: object;\n }>;\n}\n\n/**\n * Used to geocode a [batch](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-geocode-addresses.htm) of addresses.\n *\n * ```js\n * import { bulkGeocode } from '@esri/arcgis-rest-geocoding';\n * import { ApplicationCredentialsManager } from '@esri/arcgis-rest-request';\n *\n * const addresses = [\n * { \"OBJECTID\": 1, \"SingleLine\": \"380 New York Street 92373\" },\n * { \"OBJECTID\": 2, \"SingleLine\": \"1 World Way Los Angeles 90045\" }\n * ];\n *\n * bulkGeocode({ addresses, authentication: session })\n * .then((response) => {\n * response.locations[0].location; // => { x: -117, y: 34, spatialReference: { wkid: 4326 } }\n * });\n * ```\n *\n * @param requestOptions - Request options to pass to the geocoder, including an array of addresses and authentication session.\n * @returns A Promise that will resolve with the data from the response. The spatial reference will be added to address locations unless `rawResponse: true` was passed.\n */\nexport function bulkGeocode(\n requestOptions: IBulkGeocodeOptions // must POST, which is the default\n): Promise<IBulkGeocodeResponse> {\n const options: IBulkGeocodeOptions = {\n endpoint: ARCGIS_ONLINE_BULK_GEOCODING_URL,\n params: {},\n ...requestOptions\n };\n\n options.params.addresses = {\n records: requestOptions.addresses.map((address) => {\n return { attributes: address };\n })\n };\n\n // the SAS service does not support anonymous requests\n if (\n !requestOptions.authentication &&\n options.endpoint === ARCGIS_ONLINE_BULK_GEOCODING_URL\n ) {\n return Promise.reject(\n \"bulk geocoding using the ArcGIS service requires authentication\"\n );\n }\n\n return request(\n `${cleanUrl(options.endpoint)}/geocodeAddresses`,\n options\n ).then((response) => {\n if (options.rawResponse) {\n return response;\n }\n const sr = response.spatialReference;\n response.locations.forEach(function (address: { location: IPoint }) {\n if (address.location) {\n address.location.spatialReference = sr;\n }\n });\n return response;\n });\n}\n"]}
|
package/dist/esm/geocode.d.ts
CHANGED
|
@@ -55,14 +55,16 @@ export interface IGeocodeResponse {
|
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
|
-
*
|
|
58
|
+
* Used to determine the location of a single address or point of interest. See the [REST Documentation](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-find-address-candidates.htm) for more information.
|
|
59
|
+
*
|
|
60
|
+
* ```js
|
|
59
61
|
* import { geocode } from '@esri/arcgis-rest-geocoding';
|
|
60
|
-
*
|
|
62
|
+
*
|
|
61
63
|
* geocode("LAX")
|
|
62
64
|
* .then((response) => {
|
|
63
65
|
* response.candidates[0].location; // => { x: -118.409, y: 33.943, spatialReference: ... }
|
|
64
66
|
* });
|
|
65
|
-
*
|
|
67
|
+
*
|
|
66
68
|
* geocode({
|
|
67
69
|
* address: "1600 Pennsylvania Ave",
|
|
68
70
|
* postal: 20500,
|
|
@@ -72,7 +74,7 @@ export interface IGeocodeResponse {
|
|
|
72
74
|
* response.candidates[1].location; // => { x: -77.036533, y: 38.898719, spatialReference: ... }
|
|
73
75
|
* });
|
|
74
76
|
* ```
|
|
75
|
-
*
|
|
77
|
+
*
|
|
76
78
|
* @param address String representing the address or point of interest or RequestOptions to pass to the endpoint.
|
|
77
79
|
* @returns A Promise that will resolve with address candidates for the request. The spatial reference will be added to candidate locations and extents unless `rawResponse: true` was passed.
|
|
78
80
|
*/
|
package/dist/esm/geocode.js
CHANGED
|
@@ -4,14 +4,16 @@ import { request, cleanUrl, appendCustomParams } from "@esri/arcgis-rest-request
|
|
|
4
4
|
import { ARCGIS_ONLINE_GEOCODING_URL } from "./helpers.js";
|
|
5
5
|
import { arcgisToGeoJSON } from "@terraformer/arcgis";
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Used to determine the location of a single address or point of interest. See the [REST Documentation](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-find-address-candidates.htm) for more information.
|
|
8
|
+
*
|
|
9
|
+
* ```js
|
|
8
10
|
* import { geocode } from '@esri/arcgis-rest-geocoding';
|
|
9
|
-
*
|
|
11
|
+
*
|
|
10
12
|
* geocode("LAX")
|
|
11
13
|
* .then((response) => {
|
|
12
14
|
* response.candidates[0].location; // => { x: -118.409, y: 33.943, spatialReference: ... }
|
|
13
15
|
* });
|
|
14
|
-
*
|
|
16
|
+
*
|
|
15
17
|
* geocode({
|
|
16
18
|
* address: "1600 Pennsylvania Ave",
|
|
17
19
|
* postal: 20500,
|
|
@@ -21,7 +23,7 @@ import { arcgisToGeoJSON } from "@terraformer/arcgis";
|
|
|
21
23
|
* response.candidates[1].location; // => { x: -77.036533, y: 38.898719, spatialReference: ... }
|
|
22
24
|
* });
|
|
23
25
|
* ```
|
|
24
|
-
*
|
|
26
|
+
*
|
|
25
27
|
* @param address String representing the address or point of interest or RequestOptions to pass to the endpoint.
|
|
26
28
|
* @returns A Promise that will resolve with address candidates for the request. The spatial reference will be added to candidate locations and extents unless `rawResponse: true` was passed.
|
|
27
29
|
*/
|
package/dist/esm/geocode.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geocode.js","sourceRoot":"","sources":["../../src/geocode.ts"],"names":[],"mappings":"AAAA;gBACgB;AAEhB,OAAO,EACL,OAAO,EACP,QAAQ,EACR,kBAAkB,EAInB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,2BAA2B,EAAoB,MAAM,cAAc,CAAC;AAE7E,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AA0DtD
|
|
1
|
+
{"version":3,"file":"geocode.js","sourceRoot":"","sources":["../../src/geocode.ts"],"names":[],"mappings":"AAAA;gBACgB;AAEhB,OAAO,EACL,OAAO,EACP,QAAQ,EACR,kBAAkB,EAInB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,2BAA2B,EAAoB,MAAM,cAAc,CAAC;AAE7E,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AA0DtD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,OAAO,CACrB,OAAiC;IAEjC,IAAI,OAAO,GAAoB,EAAE,CAAC;IAClC,IAAI,QAAgB,CAAC;IAErB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QAC/B,OAAO,CAAC,MAAM,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;QACzC,QAAQ,GAAG,2BAA2B,CAAC;KACxC;SAAM;QACL,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,2BAA2B,CAAC;QAC3D,OAAO,GAAG,kBAAkB,CAC1B,OAAO,EACP;YACE,YAAY;YACZ,SAAS;YACT,UAAU;YACV,UAAU;YACV,cAAc;YACd,MAAM;YACN,WAAW;YACX,QAAQ;YACR,QAAQ;YACR,WAAW;YACX,aAAa;YACb,WAAW;YACX,UAAU;SACX,EACD,EAAE,MAAM,oBAAO,OAAO,CAAC,MAAM,CAAE,EAAE,CAClC,CAAC;KACH;IAED,sDAAsD;IACtD,OAAO,OAAO,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,wBAAwB,EAAE,OAAO,CAAC,CAAC,IAAI,CACzE,CAAC,QAAQ,EAAE,EAAE;QACX,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,WAAW,EAAE;YACtD,OAAO,QAAQ,CAAC;SACjB;QACD,MAAM,EAAE,GAAsB,QAAQ,CAAC,gBAAgB,CAAC;QACxD,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,SAGrC;YACC,SAAS,CAAC,QAAQ,CAAC,gBAAgB,GAAG,EAAE,CAAC;YACzC,IAAI,SAAS,CAAC,MAAM,EAAE;gBACpB,SAAS,CAAC,MAAM,CAAC,gBAAgB,GAAG,EAAE,CAAC;aACxC;QACH,CAAC,CAAC,CAAC;QAEH,UAAU;QACV,IAAI,EAAE,CAAC,IAAI,KAAK,IAAI,EAAE;YACpB,MAAM,QAAQ,GAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAc,EAAE,EAAE;gBAC1D,OAAO;oBACL,IAAI,EAAE,SAAS;oBACf,QAAQ,EAAE,eAAe,CAAC,SAAS,CAAC,QAAQ,CAAC;oBAC7C,UAAU,EAAE,MAAM,CAAC,MAAM,CACvB;wBACE,OAAO,EAAE,SAAS,CAAC,OAAO;wBAC1B,KAAK,EAAE,SAAS,CAAC,KAAK;qBACvB,EACD,SAAS,CAAC,UAAU,CACrB;iBACF,CAAC;YACJ,CAAC,CAAC,CAAC;YAEH,QAAQ,CAAC,OAAO,GAAG;gBACjB,IAAI,EAAE,mBAAmB;gBACzB,QAAQ;aACT,CAAC;SACH;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n request,\n cleanUrl,\n appendCustomParams,\n IExtent,\n ISpatialReference,\n IPoint\n} from \"@esri/arcgis-rest-request\";\n\nimport { ARCGIS_ONLINE_GEOCODING_URL, IEndpointOptions } from \"./helpers.js\";\n\nimport { arcgisToGeoJSON } from \"@terraformer/arcgis\";\n\nexport interface IGeocodeOptions extends IEndpointOptions {\n /**\n * use this if all your address info is contained in a single string.\n */\n singleLine?: string;\n address?: string;\n address2?: string;\n address3?: string;\n neighborhood?: string;\n city?: string;\n subregion?: string;\n outFields?: \"*\" | string[];\n /**\n * The World Geocoding Service expects US states to be passed in as a 'region'.\n */\n region?: string;\n postal?: number;\n postalExt?: number;\n countryCode?: string;\n /**\n * You can create an autocomplete experience by making a call to suggest with partial text and then passing through the magicKey and complete address that are returned to geocode.\n *\n * ```js\n * import { suggest, geocode } from '@esri/arcgis-rest-geocoding';\n *\n * suggest(\"LAX\")\n * .then((response) => {\n * geocode({\n * singleLine: response.suggestions[1].text,\n * magicKey: response.suggestions[0].magicKey\n * })\n * })\n * ```\n */\n magicKey?: string;\n}\n\nexport interface IGeocodeResponse {\n spatialReference: ISpatialReference;\n candidates: Array<{\n address: string;\n location: IPoint;\n extent?: IExtent;\n score: number;\n attributes: object;\n }>;\n geoJson?: {\n type: string;\n features: Array<{\n type: string;\n geometry: object;\n properties: any;\n }>;\n };\n}\n\n/**\n * Used to determine the location of a single address or point of interest. See the [REST Documentation](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-find-address-candidates.htm) for more information.\n *\n * ```js\n * import { geocode } from '@esri/arcgis-rest-geocoding';\n *\n * geocode(\"LAX\")\n * .then((response) => {\n * response.candidates[0].location; // => { x: -118.409, y: 33.943, spatialReference: ... }\n * });\n *\n * geocode({\n * address: \"1600 Pennsylvania Ave\",\n * postal: 20500,\n * countryCode: \"USA\"\n * })\n * .then((response) => {\n * response.candidates[1].location; // => { x: -77.036533, y: 38.898719, spatialReference: ... }\n * });\n * ```\n *\n * @param address String representing the address or point of interest or RequestOptions to pass to the endpoint.\n * @returns A Promise that will resolve with address candidates for the request. The spatial reference will be added to candidate locations and extents unless `rawResponse: true` was passed.\n */\nexport function geocode(\n address: string | IGeocodeOptions\n): Promise<IGeocodeResponse> {\n let options: IGeocodeOptions = {};\n let endpoint: string;\n\n if (typeof address === \"string\") {\n options.params = { singleLine: address };\n endpoint = ARCGIS_ONLINE_GEOCODING_URL;\n } else {\n endpoint = address.endpoint || ARCGIS_ONLINE_GEOCODING_URL;\n options = appendCustomParams<IGeocodeOptions>(\n address,\n [\n \"singleLine\",\n \"address\",\n \"address2\",\n \"address3\",\n \"neighborhood\",\n \"city\",\n \"subregion\",\n \"region\",\n \"postal\",\n \"postalExt\",\n \"countryCode\",\n \"outFields\",\n \"magicKey\"\n ],\n { params: { ...address.params } }\n );\n }\n\n // add spatialReference property to individual matches\n return request(`${cleanUrl(endpoint)}/findAddressCandidates`, options).then(\n (response) => {\n if (typeof address !== \"string\" && address.rawResponse) {\n return response;\n }\n const sr: ISpatialReference = response.spatialReference;\n response.candidates.forEach(function (candidate: {\n location: IPoint;\n extent?: IExtent;\n }) {\n candidate.location.spatialReference = sr;\n if (candidate.extent) {\n candidate.extent.spatialReference = sr;\n }\n });\n\n // geoJson\n if (sr.wkid === 4326) {\n const features = response.candidates.map((candidate: any) => {\n return {\n type: \"Feature\",\n geometry: arcgisToGeoJSON(candidate.location),\n properties: Object.assign(\n {\n address: candidate.address,\n score: candidate.score\n },\n candidate.attributes\n )\n };\n });\n\n response.geoJson = {\n type: \"FeatureCollection\",\n features\n };\n }\n\n return response;\n }\n );\n}\n"]}
|
package/dist/esm/reverse.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export interface IReverseGeocodeResponse {
|
|
|
7
7
|
location: IPoint;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
+
* Used to determine the address of a [location](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-reverse-geocode.htm).
|
|
11
|
+
*
|
|
10
12
|
* ```js
|
|
11
13
|
* import { reverseGeocode } from '@esri/arcgis-rest-geocoding';
|
|
12
14
|
* //
|
|
@@ -20,7 +22,6 @@ export interface IReverseGeocodeResponse {
|
|
|
20
22
|
* reverseGeocode({ x: -118.409, y: 33.9425 }) // wgs84 is assumed
|
|
21
23
|
* reverseGeocode({ x: -13181226, y: 4021085, spatialReference: { wkid: 3857 })
|
|
22
24
|
* ```
|
|
23
|
-
* Used to determine the address of a [location](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-reverse-geocode.htm).
|
|
24
25
|
*
|
|
25
26
|
* @param coordinates - the location you'd like to associate an address with.
|
|
26
27
|
* @param requestOptions - Additional options for the request including authentication.
|
package/dist/esm/reverse.js
CHANGED
|
@@ -11,6 +11,8 @@ function isLocation(coords) {
|
|
|
11
11
|
coords.lat !== undefined);
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
+
* Used to determine the address of a [location](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-reverse-geocode.htm).
|
|
15
|
+
*
|
|
14
16
|
* ```js
|
|
15
17
|
* import { reverseGeocode } from '@esri/arcgis-rest-geocoding';
|
|
16
18
|
* //
|
|
@@ -24,7 +26,6 @@ function isLocation(coords) {
|
|
|
24
26
|
* reverseGeocode({ x: -118.409, y: 33.9425 }) // wgs84 is assumed
|
|
25
27
|
* reverseGeocode({ x: -13181226, y: 4021085, spatialReference: { wkid: 3857 })
|
|
26
28
|
* ```
|
|
27
|
-
* Used to determine the address of a [location](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-reverse-geocode.htm).
|
|
28
29
|
*
|
|
29
30
|
* @param coordinates - the location you'd like to associate an address with.
|
|
30
31
|
* @param requestOptions - Additional options for the request including authentication.
|
package/dist/esm/reverse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reverse.js","sourceRoot":"","sources":["../../src/reverse.ts"],"names":[],"mappings":"AAAA;gBACgB;AAEhB,OAAO,
|
|
1
|
+
{"version":3,"file":"reverse.js","sourceRoot":"","sources":["../../src/reverse.ts"],"names":[],"mappings":"AAAA;gBACgB;AAEhB,OAAO,EACL,OAAO,EACP,QAAQ,EAGT,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,2BAA2B,EAAoB,MAAM,cAAc,CAAC;AAS7E,SAAS,eAAe,CACtB,MAAwE;IAExE,OAAO,CACJ,MAA2B,CAAC,MAAM,KAAK,CAAC;QACxC,MAAmC,CAAC,MAAM,KAAK,CAAC,CAClD,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CACjB,MAAwE;IAExE,OAAO,CACJ,MAAoB,CAAC,QAAQ,KAAK,SAAS;QAC3C,MAAoB,CAAC,GAAG,KAAK,SAAS,CACxC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,cAAc,CAC5B,MAA6C,EAC7C,cAAiC;IAEjC,MAAM,OAAO,mBACX,QAAQ,EAAE,2BAA2B,EACrC,MAAM,EAAE,EAAE,IACP,cAAc,CAClB,CAAC;IAEF,IAAI,eAAe,CAAC,MAAM,CAAC,EAAE;QAC3B,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;KACzC;SAAM,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE;QAC7B,IAAI,MAAM,CAAC,GAAG,EAAE;YACd,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,GAAG,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC;SAC1D;QACD,IAAI,MAAM,CAAC,QAAQ,EAAE;YACnB,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,SAAS,GAAG,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC;SACpE;KACF;SAAM;QACL,4FAA4F;QAC5F,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC;KAClC;IAED,OAAO,OAAO,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;AAC1E,CAAC;AAED,eAAe;IACb,cAAc;CACf,CAAC","sourcesContent":["/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n request,\n cleanUrl,\n IPoint,\n ILocation\n} from \"@esri/arcgis-rest-request\";\n\nimport { ARCGIS_ONLINE_GEOCODING_URL, IEndpointOptions } from \"./helpers.js\";\n\nexport interface IReverseGeocodeResponse {\n address: {\n [key: string]: any;\n };\n location: IPoint;\n}\n\nfunction isLocationArray(\n coords: ILocation | IPoint | [number, number] | [number, number, number]\n): coords is [number, number] | [number, number, number] {\n return (\n (coords as [number, number]).length === 2 ||\n (coords as [number, number, number]).length === 3\n );\n}\n\nfunction isLocation(\n coords: ILocation | IPoint | [number, number] | [number, number, number]\n): coords is ILocation {\n return (\n (coords as ILocation).latitude !== undefined ||\n (coords as ILocation).lat !== undefined\n );\n}\n\n/**\n * Used to determine the address of a [location](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-reverse-geocode.htm).\n *\n * ```js\n * import { reverseGeocode } from '@esri/arcgis-rest-geocoding';\n * //\n * reverseGeocode([-118.409,33.943 ]) // long, lat\n * .then((response) => {\n * response.address.PlaceName; // => \"LA Airport\"\n * });\n * // or\n * reverseGeocode({ long: -118.409, lat: 33.943 })\n * reverseGeocode({ latitude: 33.943, latitude: -118.409 })\n * reverseGeocode({ x: -118.409, y: 33.9425 }) // wgs84 is assumed\n * reverseGeocode({ x: -13181226, y: 4021085, spatialReference: { wkid: 3857 })\n * ```\n *\n * @param coordinates - the location you'd like to associate an address with.\n * @param requestOptions - Additional options for the request including authentication.\n * @returns A Promise that will resolve with the data from the response.\n */\nexport function reverseGeocode(\n coords: IPoint | ILocation | [number, number],\n requestOptions?: IEndpointOptions\n): Promise<IReverseGeocodeResponse> {\n const options: IEndpointOptions = {\n endpoint: ARCGIS_ONLINE_GEOCODING_URL,\n params: {},\n ...requestOptions\n };\n\n if (isLocationArray(coords)) {\n options.params.location = coords.join();\n } else if (isLocation(coords)) {\n if (coords.lat) {\n options.params.location = coords.long + \",\" + coords.lat;\n }\n if (coords.latitude) {\n options.params.location = coords.longitude + \",\" + coords.latitude;\n }\n } else {\n // if input is a point, we can pass it straight through, with or without a spatial reference\n options.params.location = coords;\n }\n\n return request(`${cleanUrl(options.endpoint)}/reverseGeocode`, options);\n}\n\nexport default {\n reverseGeocode\n};\n"]}
|
package/dist/esm/suggest.d.ts
CHANGED
|
@@ -7,13 +7,14 @@ export interface ISuggestResponse {
|
|
|
7
7
|
}>;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
+
* Used to return a placename [suggestion](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-suggest.htm) for a partial string.
|
|
11
|
+
*
|
|
10
12
|
* ```js
|
|
11
13
|
* import { suggest } from '@esri/arcgis-rest-geocoding';
|
|
12
14
|
* //
|
|
13
15
|
* suggest("Starb")
|
|
14
16
|
* .then(response) // response.text === "Starbucks"
|
|
15
17
|
* ```
|
|
16
|
-
* Used to return a placename [suggestion](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-suggest.htm) for a partial string.
|
|
17
18
|
*
|
|
18
19
|
* @param requestOptions - Options for the request including authentication and other optional parameters.
|
|
19
20
|
* @returns A Promise that will resolve with the data from the response.
|
package/dist/esm/suggest.js
CHANGED
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
import { request, cleanUrl } from "@esri/arcgis-rest-request";
|
|
4
4
|
import { ARCGIS_ONLINE_GEOCODING_URL } from "./helpers.js";
|
|
5
5
|
/**
|
|
6
|
+
* Used to return a placename [suggestion](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-suggest.htm) for a partial string.
|
|
7
|
+
*
|
|
6
8
|
* ```js
|
|
7
9
|
* import { suggest } from '@esri/arcgis-rest-geocoding';
|
|
8
10
|
* //
|
|
9
11
|
* suggest("Starb")
|
|
10
12
|
* .then(response) // response.text === "Starbucks"
|
|
11
13
|
* ```
|
|
12
|
-
* Used to return a placename [suggestion](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-suggest.htm) for a partial string.
|
|
13
14
|
*
|
|
14
15
|
* @param requestOptions - Options for the request including authentication and other optional parameters.
|
|
15
16
|
* @returns A Promise that will resolve with the data from the response.
|
package/dist/esm/suggest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggest.js","sourceRoot":"","sources":["../../src/suggest.ts"],"names":[],"mappings":"AAAA;gBACgB;AAEhB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,2BAA2B,EAAoB,MAAM,cAAc,CAAC;AAU7E
|
|
1
|
+
{"version":3,"file":"suggest.js","sourceRoot":"","sources":["../../src/suggest.ts"],"names":[],"mappings":"AAAA;gBACgB;AAEhB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,2BAA2B,EAAoB,MAAM,cAAc,CAAC;AAU7E;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,OAAO,CACrB,WAAmB,EACnB,cAAiC;IAEjC,MAAM,OAAO,mBACX,QAAQ,EAAE,2BAA2B,EACrC,MAAM,EAAE,EAAE,IACP,cAAc,CAClB,CAAC;IAEF,OAAO,CAAC,MAAM,CAAC,IAAI,GAAG,WAAW,CAAC;IAElC,OAAO,OAAO,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AACnE,CAAC;AAED,eAAe;IACb,OAAO;CACR,CAAC","sourcesContent":["/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request, cleanUrl } from \"@esri/arcgis-rest-request\";\n\nimport { ARCGIS_ONLINE_GEOCODING_URL, IEndpointOptions } from \"./helpers.js\";\n\nexport interface ISuggestResponse {\n suggestions: Array<{\n text: string;\n magicKey: string;\n isCollection: boolean;\n }>;\n}\n\n/**\n * Used to return a placename [suggestion](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-suggest.htm) for a partial string.\n *\n * ```js\n * import { suggest } from '@esri/arcgis-rest-geocoding';\n * //\n * suggest(\"Starb\")\n * .then(response) // response.text === \"Starbucks\"\n * ```\n *\n * @param requestOptions - Options for the request including authentication and other optional parameters.\n * @returns A Promise that will resolve with the data from the response.\n */\nexport function suggest(\n partialText: string,\n requestOptions?: IEndpointOptions\n): Promise<ISuggestResponse> {\n const options: IEndpointOptions = {\n endpoint: ARCGIS_ONLINE_GEOCODING_URL,\n params: {},\n ...requestOptions\n };\n\n options.params.text = partialText;\n\n return request(`${cleanUrl(options.endpoint)}/suggest`, options);\n}\n\nexport default {\n suggest\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esri/arcgis-rest-geocoding",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Geocoding helpers for @esri/arcgis-rest-js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -31,7 +31,9 @@
|
|
|
31
31
|
"postbuild": "node ../../scripts/create-dist-package-jsons.js",
|
|
32
32
|
"build:bundled": "rollup -c ../../rollup.js",
|
|
33
33
|
"build:cjs": "tsc --outDir ./dist/cjs -m commonjs",
|
|
34
|
+
"postbuild:cjs": "node ../../scripts/create-dist-package-jsons.js",
|
|
34
35
|
"build:esm": "tsc --outDir ./dist/esm --declaration",
|
|
36
|
+
"postbuild:esm": "node ../../scripts/create-dist-package-jsons.js",
|
|
35
37
|
"dev": "npm-run-all --parallel dev:*",
|
|
36
38
|
"dev:bundled": "rollup -w -c ../../rollup.js",
|
|
37
39
|
"dev:cjs": "tsc -w --outDir ./dist/cjs -m commonjs",
|
|
@@ -46,10 +48,10 @@
|
|
|
46
48
|
"tslib": "^2.3.0"
|
|
47
49
|
},
|
|
48
50
|
"peerDependencies": {
|
|
49
|
-
"@esri/arcgis-rest-request": "4.0.
|
|
51
|
+
"@esri/arcgis-rest-request": "4.0.1"
|
|
50
52
|
},
|
|
51
53
|
"devDependencies": {
|
|
52
|
-
"@esri/arcgis-rest-request": "4.0.
|
|
54
|
+
"@esri/arcgis-rest-request": "4.0.1"
|
|
53
55
|
},
|
|
54
56
|
"contributors": [
|
|
55
57
|
"Patrick Arlt <parlt@esri.com> (http://patrickarlt.com/)"
|
|
@@ -65,5 +67,14 @@
|
|
|
65
67
|
},
|
|
66
68
|
"publishConfig": {
|
|
67
69
|
"access": "public"
|
|
70
|
+
},
|
|
71
|
+
"esri": {
|
|
72
|
+
"keyExports": [
|
|
73
|
+
"bulkGeocode",
|
|
74
|
+
"geocode",
|
|
75
|
+
"getGeocodeService",
|
|
76
|
+
"reverseGeocode",
|
|
77
|
+
"suggest"
|
|
78
|
+
]
|
|
68
79
|
}
|
|
69
80
|
}
|