@esri/arcgis-rest-geocoding 4.0.3 → 4.8.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/dist/bundled/geocoding.esm.js +8 -8
- package/dist/bundled/geocoding.esm.js.map +1 -1
- package/dist/bundled/geocoding.esm.min.js +8 -8
- package/dist/bundled/geocoding.esm.min.js.map +1 -1
- package/dist/bundled/geocoding.umd.js +463 -465
- package/dist/bundled/geocoding.umd.js.map +1 -1
- package/dist/bundled/geocoding.umd.min.js +9 -9
- package/dist/bundled/geocoding.umd.min.js.map +1 -1
- package/dist/cjs/bulk.js +1 -2
- package/dist/cjs/bulk.js.map +1 -1
- package/dist/cjs/geocode.js +1 -2
- package/dist/cjs/geocode.js.map +1 -1
- package/dist/cjs/helpers.js +2 -2
- package/dist/cjs/helpers.js.map +1 -1
- package/dist/cjs/index.js +5 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/reverse.js +2 -3
- package/dist/cjs/reverse.js.map +1 -1
- package/dist/cjs/suggest.js +1 -2
- package/dist/cjs/suggest.js.map +1 -1
- package/dist/esm/bulk.js.map +1 -1
- package/dist/esm/geocode.js.map +1 -1
- package/dist/esm/reverse.d.ts +1 -1
- package/dist/esm/reverse.js +1 -1
- package/dist/esm/reverse.js.map +1 -1
- package/package.json +2 -2
package/dist/cjs/reverse.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.
|
|
3
3
|
* Apache-2.0 */
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.reverseGeocode =
|
|
5
|
+
exports.reverseGeocode = reverseGeocode;
|
|
6
6
|
const arcgis_rest_request_1 = require("@esri/arcgis-rest-request");
|
|
7
7
|
const helpers_js_1 = require("./helpers.js");
|
|
8
8
|
function isLocationArray(coords) {
|
|
@@ -30,7 +30,7 @@ function isLocation(coords) {
|
|
|
30
30
|
* reverseGeocode({ x: -13181226, y: 4021085, spatialReference: { wkid: 3857 })
|
|
31
31
|
* ```
|
|
32
32
|
*
|
|
33
|
-
* @param
|
|
33
|
+
* @param coords - the location you'd like to associate an address with.
|
|
34
34
|
* @param requestOptions - Additional options for the request including authentication.
|
|
35
35
|
* @returns A Promise that will resolve with the data from the response.
|
|
36
36
|
*/
|
|
@@ -53,7 +53,6 @@ function reverseGeocode(coords, requestOptions) {
|
|
|
53
53
|
}
|
|
54
54
|
return (0, arcgis_rest_request_1.request)(`${(0, arcgis_rest_request_1.cleanUrl)(options.endpoint)}/reverseGeocode`, options);
|
|
55
55
|
}
|
|
56
|
-
exports.reverseGeocode = reverseGeocode;
|
|
57
56
|
exports.default = {
|
|
58
57
|
reverseGeocode
|
|
59
58
|
};
|
package/dist/cjs/reverse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reverse.js","sourceRoot":"","sources":["../../src/reverse.ts"],"names":[],"mappings":";AAAA;gBACgB
|
|
1
|
+
{"version":3,"file":"reverse.js","sourceRoot":"","sources":["../../src/reverse.ts"],"names":[],"mappings":";AAAA;gBACgB;;AAyDhB,wCAyBC;AAhFD,mEAKmC;AAEnC,6CAA6E;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,SAAgB,cAAc,CAC5B,MAA6C,EAC7C,cAAiC;IAEjC,MAAM,OAAO,mBACX,QAAQ,EAAE,wCAA2B,EACrC,MAAM,EAAE,EAAE,IACP,cAAc,CAClB,CAAC;IAEF,IAAI,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5B,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;IAC1C,CAAC;SAAM,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9B,IAAI,MAAM,CAAC,GAAG,EAAE,CAAC;YACf,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,GAAG,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC;QAC3D,CAAC;QACD,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YACpB,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,SAAS,GAAG,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC;QACrE,CAAC;IACH,CAAC;SAAM,CAAC;QACN,4FAA4F;QAC5F,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC;IACnC,CAAC;IAED,OAAO,IAAA,6BAAO,EAAC,GAAG,IAAA,8BAAQ,EAAC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;AAC1E,CAAC;AAED,kBAAe;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 coords - 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/cjs/suggest.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.
|
|
3
3
|
* Apache-2.0 */
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.suggest =
|
|
5
|
+
exports.suggest = suggest;
|
|
6
6
|
const arcgis_rest_request_1 = require("@esri/arcgis-rest-request");
|
|
7
7
|
const helpers_js_1 = require("./helpers.js");
|
|
8
8
|
/**
|
|
@@ -23,7 +23,6 @@ function suggest(partialText, requestOptions) {
|
|
|
23
23
|
options.params.text = partialText;
|
|
24
24
|
return (0, arcgis_rest_request_1.request)(`${(0, arcgis_rest_request_1.cleanUrl)(options.endpoint)}/suggest`, options);
|
|
25
25
|
}
|
|
26
|
-
exports.suggest = suggest;
|
|
27
26
|
exports.default = {
|
|
28
27
|
suggest
|
|
29
28
|
};
|
package/dist/cjs/suggest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggest.js","sourceRoot":"","sources":["../../src/suggest.ts"],"names":[],"mappings":";AAAA;gBACgB
|
|
1
|
+
{"version":3,"file":"suggest.js","sourceRoot":"","sources":["../../src/suggest.ts"],"names":[],"mappings":";AAAA;gBACgB;;AA2BhB,0BAaC;AAtCD,mEAA8D;AAE9D,6CAA6E;AAU7E;;;;;;;;;;;;GAYG;AACH,SAAgB,OAAO,CACrB,WAAmB,EACnB,cAAiC;IAEjC,MAAM,OAAO,mBACX,QAAQ,EAAE,wCAA2B,EACrC,MAAM,EAAE,EAAE,IACP,cAAc,CAClB,CAAC;IAEF,OAAO,CAAC,MAAM,CAAC,IAAI,GAAG,WAAW,CAAC;IAElC,OAAO,IAAA,6BAAO,EAAC,GAAG,IAAA,8BAAQ,EAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AACnE,CAAC;AAED,kBAAe;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/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,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;
|
|
1
|
+
{"version":3,"file":"bulk.js","sourceRoot":"","sources":["../../src/bulk.ts"],"names":[],"mappings":"AAAA;gBACgB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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?: string | number;\n postalExt?: string | 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.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,EAIlB,IAAI,EACL,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;
|
|
1
|
+
{"version":3,"file":"geocode.js","sourceRoot":"","sources":["../../src/geocode.ts"],"names":[],"mappings":"AAAA;gBACgB;AAEhB,OAAO,EACL,OAAO,EACP,QAAQ,EACR,kBAAkB,EAIlB,IAAI,EACL,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,2BAA2B,EAAoB,MAAM,cAAc,CAAC;AAE7E,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AA0DtD;;;;;;;;;;;;;;;;;;;;;;;GAu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AAC;gBACrB,SAAS,CAAC,MAAM,CAAC,gBAAgB,GAAG,EAAE,CAAC;YACzC,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,UAAU;QACV,IAAI,EAAE,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;YACrB,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;QACJ,CAAC;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 warn\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?: string | number;\n postalExt?: string | 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 if (options.params.postal && typeof options.params.postal === \"number\") {\n warn(\n \"The postal code should be a string. \" +\n \"Issues can arise when using it as a number, especially if they start with zero.\"\n );\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
|
@@ -23,7 +23,7 @@ export interface IReverseGeocodeResponse {
|
|
|
23
23
|
* reverseGeocode({ x: -13181226, y: 4021085, spatialReference: { wkid: 3857 })
|
|
24
24
|
* ```
|
|
25
25
|
*
|
|
26
|
-
* @param
|
|
26
|
+
* @param coords - the location you'd like to associate an address with.
|
|
27
27
|
* @param requestOptions - Additional options for the request including authentication.
|
|
28
28
|
* @returns A Promise that will resolve with the data from the response.
|
|
29
29
|
*/
|
package/dist/esm/reverse.js
CHANGED
|
@@ -27,7 +27,7 @@ function isLocation(coords) {
|
|
|
27
27
|
* reverseGeocode({ x: -13181226, y: 4021085, spatialReference: { wkid: 3857 })
|
|
28
28
|
* ```
|
|
29
29
|
*
|
|
30
|
-
* @param
|
|
30
|
+
* @param coords - the location you'd like to associate an address with.
|
|
31
31
|
* @param requestOptions - Additional options for the request including authentication.
|
|
32
32
|
* @returns A Promise that will resolve with the data from the response.
|
|
33
33
|
*/
|
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,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;
|
|
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,CAAC;QAC5B,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;IAC1C,CAAC;SAAM,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9B,IAAI,MAAM,CAAC,GAAG,EAAE,CAAC;YACf,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,GAAG,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC;QAC3D,CAAC;QACD,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YACpB,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,SAAS,GAAG,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC;QACrE,CAAC;IACH,CAAC;SAAM,CAAC;QACN,4FAA4F;QAC5F,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC;IACnC,CAAC;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 coords - 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esri/arcgis-rest-geocoding",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.8.0",
|
|
4
4
|
"description": "Geocoding helpers for @esri/arcgis-rest-js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@esri/arcgis-rest-request": "^4.0.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@esri/arcgis-rest-request": "^4.0
|
|
54
|
+
"@esri/arcgis-rest-request": "^4.8.0"
|
|
55
55
|
},
|
|
56
56
|
"contributors": [
|
|
57
57
|
"Patrick Arlt <parlt@esri.com> (http://patrickarlt.com/)"
|