How to Use the identifytask class

Source: Internet
Author: User

Identifytask features:

  1. Multi-layer query supported
  2. The returned field cannot be specified.
  3. Only property information can be queried, and space information cannot be queried.
  4. Interaction Process with users

Steps:

  1. Create an identifytask class
  2. Create identifyparameters class
  3. Execute the identifytask method Execute
  4. Receive and Display Results

Sample Code:

<? XML version = "1.0" encoding = "UTF-8"?>
<S: Application xmlns: FX = "http://ns.adobe.com/mxml/2009"
Xmlns: S = "Library: // ns.adobe.com/flex/spark"
Xmlns: MX = "Library: // ns.adobe.com/flex/mx" minwidth = "955" minheight = "600" xmlns: ESRI = "http://www.esri.com/2008/ags">
<FX: SCRIPT>
<! [CDATA [
Import com. ESRI. AGS. Graphic;
Import com. ESRI. AGS. Events. identifyevent;
Import com. ESRI. AGS. Events. mapmouseevent;
Import com. ESRI. AGS. Geometry. mappoint;
Import com. ESRI. AGS. symbols. infosymbol;
Import com. ESRI. AGS. Tasks. supportclasses. identifyresult;

Import MX. rpc. asyncresponder;

Protected function mymap_mapclickhandler (Event: mapmouseevent): void // map mapclick event
{
VaR point: mappoint = event. mappoint; // obtain the mappoint from the map mapclick event parameter event.
VaR grahic: graphic = new graphic (point); // use a vertex as a parameter to construct a graphic
Mygraphicslayer. Clear (); // clear graphicslayer content

// Construct the identifyparameters Parameter
Myparameters. DPI = 96; // 96 pixels per inch, resolution
Myparameters. Height = mymap. height; // value map height
Myparameters. width = mymap. width; // value map width
Myparameters. layeroption = identifyparameters. layer_option_all; // query all layers
Myparameters. Tolerance = 3; // margin difference
Myparameters. mapextent = mymap. extent; // value range of the map
Myparameters. spatialreference = mymap. spatialreference; // map space reference
Myparameters. Geometry = grahic. geometry; // you can specify the value of graphic when a map is clicked.
Myparameters. returngeometry = true; // returns the ry.

Identifytask.exe cute (myparameters, new asyncresponder (onok, onerr, point) // executes the execute method of identify and transmits the point as a parameter.
}

Protected function onok (OBJ: array, Token: mappoint): void // obj is defined as a data, because multiple clicks will generate multiple identifyresults
{
For each (VAR identifyresult: identifyresult in OBJ) // traverses the identifyresult object in OBJ.
{
VaR pointgraphic: graphic = new graphic (token); // click a point on the map to construct a graphic object.
Pointgraphic. Attributes = identifyresult. feature. attributes; // copy the attribute of the feature obtained after an identify operation.
Pointgraphic. symbol = new infosymbol (); // This point is signed. Note that there is no difference between the infosymbol object and the image or the symbol.
Mygraphicslayer. Add (pointgraphic); // Add

VaR newgraphic: graphic = identifyresult. feature; // obtain the feature obtained after identify execution
Mygraphicslayer. Add (newgraphic); // Add the obtained feature to graphic
}

}

Protected function onerr (OBJ: object, Token: Object): void
{

}

]>
</FX: SCRIPT>
<FX: declarations>
<! -- Place non-visual elements (e.g., services, value objects) Here -->
<ESRI: identifytask id = "identifytask" url = "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer" showbusycursor = "true"/>
<ESRI: identifyparameters id = "myparameters"/>
</FX: declarations>
<ESRI: Map id = "mymap" mapclick = "mymap_mapclickhandler (event)">
<ESRI: arcgistiledmapservicelayer url = "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
<ESRI: graphicslayer id = "mygraphicslayer"/>
</ESRI: Map>
</S: Application>

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.