Gis-010-arcgis JS Three types of query mode

Source: Internet
Author: User
Tags polyline

Querytask, Findtask, Identifytask are inherited from the ESRI.ArcGIS.Client.Tasks:

1, Querytask: is a spatial and property query function class, it can be in a map service in a sub-layer query, by the way, Querytask query map service does not have to be loaded into map for display. The execution of Querytask requires two prerequisites: One is the URL of the layer that needs to be queried, and the other is the filter condition for the query.

Here is the basic process of querytask:

Create a new querytask querytask querytask = new Querytask ("Http://sampleserver1.arcgisonline.com/ArcGIS/rest/services            /DEMOGRAPHICS/ESRI_CENSUS_USA/MAPSERVER/5 ");            Query Object Query query = new query (); Incoming spatial geometry range, can not be set//legal geometry Type is extent, point, Multipoint, Polyline, Polygon query.            Geometry = Geometry; Whether to return query results for spatial geometry information.            Returngeometry = true; The fields that the query results return, fields must be in the layer, and the case of the fields can be ignored by query.            Outfields.addrange (new string[] {"AreaName", "POP2000"}); Quer. Outfield.add ("*"); Returns all fields//the Where condition of the query, which can be any legitimate SQL statement and can be set without query.            Where = "POP2000 > 350000";            Asynchronous query, need to bind querytask two events, through executecompleted get query results querytask.executecompleted + = querytask_executecompleted;            querytask.failed + = querytask_failed;            Querytask.executeasync (query); synchronous queries, no binding events, direct return to query results//featureset featureset = querytask.execUte (query); 

2. Findtask: Allows query based on attribute field values for features of one or more layers in the map (search-one or more layers-a map for features with attribute values that match O R contain an input value). Findtask cannot make spatial queries because Findtask can query multiple layers, and all its URL properties need to point to the rest URL of the map service being queried, rather than specifying the URL of a layer, as querytask requires.

Here is the basic process of findtask:

 Create a new Find task Findtask Findtask = new Findtask ("Http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/D            emographics/esri_census_usa/mapserver/");            Asynchronous execution, binding event findtask.executecompleted + = findtask_executecompleted;            findtask.failed + = findtask_failed;            Initialize the findparameters parameter findparameters findparameters = new Findparameters (); FindParameters.LayerIds.AddRange (New int[] {3}); The found Layer FindParameters.SearchFields.AddRange (new string[] {"NAME"});            Lookup field Range findparameters.returngeometry = true; Findparameters.searchtext = Findtextbox.text; Find the "attribute value"//Set query for Layerdefinitions ESRI. ArcGIS.Client.LayerDefinition mydefinition = new ESRI.            ArcGIS.Client.LayerDefinition ();            Mydefinition.layerid = 3; Setting Layerdefinition, the property field "Name" is the same as the where statement in query with the SET statement for the layer with ID 0//layerdefinition mydefinition.definit Ion = "NAME = ' XXX '; Create a Observablecollection,add set of Layerdefinition System.collections.objectmodel.observablecollection<layerde finition> myobservablecollection = new System.collections.objectmodel.observablecollection<layerdefini            Tion> ();            Myobservablecollection.add (mydefinition); Findparameters.layerdefinitions = myobservablecollection; Set the Layerdefinitions//Asynchronous Execution Findtask.executeasync (findparameters) for the query;

3, Identifytask: is a feature class that identifies the feature (Feature) in the map service. The identifytask allows you to search for features in the map layer that intersect the input geometry (search the layers in a map for features, intersect an input geometry). Because the query is also in multiple layers, the URL of the task is the address of the dynamic layer service. Similarly, the returned features can be added to the graphicslayer of the map as graphic.

The basic process is as follows:

            Create a new identify task Identifytask Identifytask = new Identifytask ("Http://sampleserver1.arcgisonline            . Com/arcgis/rest/services/demographics/esri_census_usa/mapserver ");            Asynchronous execution, binding event identifytask.executecompleted + = identifytask_executecompleted;            identifytask.failed + = identifytask_failed;            Initialize Identify parameters identifyparameters identifyparameters = new Identifyparameters ();            Identifyparameters.layeroption = Layeroption.all;            Pass map properties to identify parameters identifyparameters.mapextent = mymap.extent;            Identifyparameters.width = (int) mymap.actualwidth;            Identifyparameters.height = (int) mymap.actualheight; The input geometry parameter is a point, and args comes from click event Identifyparameters.geometry = args. MapPoint; Point Envelop Extent polyline polygon//Set up the query for Layerdefinitions ESRI. ArcGIS.Client.LayerDefinition mydefinition = new ESRI. ArcGIS.Client.LayerDefInition ();            Mydefinition.layerid = 3; Setting Layerdefinition, the property field "Name" is the same as the where statement in query with the SET statement for the layer with ID 0//layerdefinition mydefinition.definit            Ion = "NAME = ' XXX '"; Create a Observablecollection,add set of Layerdefinition System.collections.objectmodel.observablecollection<layerde finition> myobservablecollection = new System.collections.objectmodel.observablecollection<layerdefini            Tion> ();            Myobservablecollection.add (mydefinition); Identifyparameters.layerdefinitions = myobservablecollection; Set the Layerdefinitions//Asynchronous Execution Identifytask.executeasync (identifyparameters) for the query;

Return results for three queries:

Querytask: The return is a featureset. Featureset.features[i] can be added to the Graphicslayer display, or you can get property information through the Attributes property field.

Findtask: A findresults array is returned, Findresults[i].feature can be added to the Graphicslayer, or property information can be obtained from the Attributes attribute field.

Identifytask: A identifyresults array is returned, Identifyresults[i].feature can be added to the Graphicslayer, or property information can be obtained from the Attributes attribute field.

Transferred from: http://www.cnblogs.com/luxiaoxun/p/3297654.html

Reference:

Http://help.arcgis.com/en/webapi/silverlight/1.2/help/index.html
Http://resources.arcgis.com/en/help/runtime-wpf/concepts/index.html#/Querying_and_searching_overview/0170000000m4000000/

Gis-010-arcgis JS three query mode (GO)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.