From 24485beed8a58bcd3e236124d83b6f4908d51bb4 Mon Sep 17 00:00:00 2001 From: strajuser Date: Fri, 7 Jul 2017 12:12:40 +0300 Subject: [PATCH] - definitions for Find task --- types/esri-leaflet/esri-leaflet-tests.ts | 41 ++++++- types/esri-leaflet/index.d.ts | 143 ++++++++++++++++++++++- 2 files changed, 182 insertions(+), 2 deletions(-) diff --git a/types/esri-leaflet/esri-leaflet-tests.ts b/types/esri-leaflet/esri-leaflet-tests.ts index 06b27c07e3..cb68af894e 100644 --- a/types/esri-leaflet/esri-leaflet-tests.ts +++ b/types/esri-leaflet/esri-leaflet-tests.ts @@ -466,4 +466,43 @@ identifyFeatures .on(map) .at([45.543, -122.621]) .layers('visible:1') - .run(function(error, featureCollection, response) { }); \ No newline at end of file + .run(function(error, featureCollection, response) { }); + +let findOptions: L.esri.FindOptions; +let find: L.esri.Find; + +findOptions = { +}; +findOptions = { + url: 'https://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer/0', + proxy: '//localhost/proxy', + useCors: true, + timeout: 1000 +}; + +find = L.esri.find(findOptions); +find = L.esri.find({}); +find = L.esri.find({ + url: 'https://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer/0', + proxy: '//localhost/proxy', + useCors: true, + timeout: 1000 +}); + +find = new L.esri.Find(findOptions); +find = new L.esri.Find({}); +find = new L.esri.Find({ + url: 'https://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer/0', + proxy: '//localhost/proxy', + useCors: true, + timeout: 1000 +}); + +find.layers('18') + .text('Colorado'); +find.run(function(error, featureCollection, response){ }); + +find.layers('13') + .text('198133') + .fields('GNIS_ID'); +find.run(function(error, featureCollection, response) { }); diff --git a/types/esri-leaflet/index.d.ts b/types/esri-leaflet/index.d.ts index 7a5861933f..28bcfcec9d 100644 --- a/types/esri-leaflet/index.d.ts +++ b/types/esri-leaflet/index.d.ts @@ -1031,7 +1031,7 @@ declare namespace L { * @returns {this} * @memberof IdentifyFeatures */ - layers(layers: string): this; + layers(layers: string | Array): this; /** * Return only this many decimal points of precision in the output geometries. * @@ -1083,6 +1083,147 @@ declare namespace L { * @returns {IdentifyFeatures} */ function identifyFeatures(options: IdentifyFeaturesOptions | ImageService): IdentifyFeatures; + + /** + * Options for Find Task + * + * @interface FindOptions + * @extends {ServiceOptions} + */ + interface FindOptions extends ServiceOptions { } + + /** + * L.esri.Find is an abstraction for the find API included in Map Services. It provides a chainable API for building request parameters and executing find tasks. + * + * @class Find + * @extends {Task} + */ + class Find extends Task { + constructor(options: FindOptions | MapService); + /** + * Text that is searched across the layers and fields the user specifies. + * + * @param {string} text + * @returns {this} + * @memberof Find + */ + text(text: string): this; + /** + * When true find task will search for a value that contains the searchText. When false it will do an exact match on the searchText string. Default is true. + * + * @param {boolean} contains + * @returns {this} + * @memberof Find + */ + contains(contains: boolean): this; + /** + * An array or comma-separated list of field names to search. If not specified, all fields are searched. + * + * @param {(string | Array)} fields + * @returns {this} + * @memberof Find + */ + fields(fields: string | Array): this; + /** + * The well known ID (ex. 4326) for the results. + * + * @param {number} sr + * @returns {this} + * @memberof Find + */ + spatialReference(sr: number): this; + /** + * Add a layer definition to the find task. + * + * @param {number} id + * @param {string} where + * @returns {this} + * @memberof Find + */ + layerDef(id: number, where: string): this; + /** + * Layers to perform find task on. Accepts an array of layer IDs or comma-separated list. + * + * @param {(string | Array)} layers + * @returns {this} + * @memberof Find + */ + layers(layers: string | Array): this; + /** + * Return geometry with results. Default is true. + * + * @param {boolean} returnGeometry + * @returns {this} + * @memberof Find + */ + returnGeometry(returnGeometry: boolean): this; + /** + * Specifies the maximum allowable offset to be used for generalizing geometries returned by the find task. + * + * @param {number} maxAllowableOffset + * @returns {this} + * @memberof Find + */ + maxAllowableOffset(maxAllowableOffset: number): this; + /** + * Specifies the number of decimal places in returned geometries. + * + * @param {number} precision + * @returns {this} + * @memberof Find + */ + precision(precision: number): this; + /** + * Include Z values in the results. Default value is true. This parameter only applies if returnGeometry=true. + * + * @param {boolean} returnZ + * @returns {this} + * @memberof Find + */ + returnZ(returnZ: boolean): this; + /** + * Includes M values if the features have them. Default value is false. This parameter only applies if returnGeometry=true. + * + * @param {boolean} returnM + * @returns {this} + * @memberof Find + */ + returnM(returnM: boolean): this; + /** + * Property used for adding new layers or modifying the data source of existing ones in the current map service. + * + * @param {*} dynamicLayers + * @returns {this} + * @memberof Find + */ + dynamicLayers(dynamicLayers: any): this; + /** + * Simplify the geometries of the output features for the current map view. the factor parameter controls the amount of simplification between 0 (no simplification) and 1 (simplify to the most basic shape possible). + * + * @param {L.Map} map + * @param {number} factor + * @returns {this} + * @memberof Find + */ + simplify(map: L.Map, factor: number): this; + /** + * Exectues the find request with the current parameters, features will be passed to callback as a GeoJSON FeatureCollection. Accepts an optional function context. + * + * @param {FeatureCallbackHandler} callback + * @param {*} [context] + * @returns {this} + * @memberof Find + */ + run(callback: FeatureCallbackHandler, context?: any): this; + } + + /** + * L.esri.Find is an abstraction for the find API included in Map Services. It provides a chainable API for building request parameters and executing find tasks. + * + * @param {(FindOptions | MapService)} options + * @returns {Find} + */ + function find(options: FindOptions | MapService): Find; } }