Arcgis api for flex (6) identify

Source: Internet
Author: User
Arcgis api for flex (6) identify
Identify is one of the most commonly used tools in GIS. In arcgis api for flex, esri provides
An Identify Task is provided to easily complete the identify function.
First, use the <esri: IdentifyTask> label to create an Identify Task.
<! -- Identify Task -->
<Esri: IdentifyTask id = "identifyTask"
IdentifyComplete = "identifyCompleteHandler (event )"
Url = "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Special
Ty/ESRI_StatesCitiesRivers_USA/MapServer "/>
When the identifyTask is executed, the system responds to the identifyComplete message.
The identify result is processed, for example, added to the Graphic layer.
Before performing identify, you must first set the identify parameter.
IdentifyParameters object. The following code is the AS3 script code used to create
IdentifyParameters and identify are executed.
Var identifyParams: IdentifyParameters = new IdentifyParameters ();
IdentifyParams. returnGeometry = true;
IdentifyParams. tolerance = 3;
IdentifyParams. width = 600;
IdentifyParams. height = 550;
IdentifyParams. geometry = geometry;
IdentifyParams. layerOption =
IdentifyParameters. LAYER_OPTION_ALL;
IdentifyParams. mapExtent = map. extent;
IdentifyTask.exe cute (identifyParams );
Tolerance indicates the tolerance radius.
Width: Width of the map currently being viewed in pixels.
Height: Height of the map currently being viewed in pixels
Geometry is used for the identification of the geometric, commonly used selection of a bit, rectangular selection, polygon selection, etc.
After setting the Token, you can directly call identifytask.exe cute (identifyParams );
.
So how can we create identify and when can we do Identify?
First, let's answer the first question. We can use the draw control to use the mouse for identify.
This is also a feature of RIA.
When will identify be implemented?
I just did it after the geometric painting of identify. Hey hey, I didn't say it. Of course I had to do it after the painting:-D.
Now let's finish the above work.
Define a draw Control
<Esriraw id = "drawToolbar" map = "{map }"
GraphicsLayer = "{myGraphicsLayer}" drawEnd = "drawEndHandler (event)">
Remember to add the response function drawEndHandler (event) of the drawEnd message.
Then respond.
Use as3 scripts to implement the drawEndHandler and identifyCompleteHandler Functions
Private function drawEndHandler (eventrawEvent): void
{
Var geometry: Geometry = event. geometry;
Var identifyParams: IdentifyParameters = new
IdentifyParameters ();
IdentifyParams. returnGeometry = true;
IdentifyParams. tolerance = 3;
IdentifyParams. width = 600;
IdentifyParams. height = 550;
IdentifyParams. geometry = geometry;
IdentifyParams. layerOption =
IdentifyParameters. LAYER_OPTION_ALL;
IdentifyParams. mapExtent = map. extent;
IdentifyTask.exe cute (identifyParams );

Private function identifyCompleteHandler
(Event: IdentifyEvent): void
{
For each (var result: IdentifyResult in
Event. identifyResults)
{
MyGraphicsLayer. add (result. feature );
}
} Code
<? Xml version = "1.0" encoding = "UTF-8"?>
<Mx: Application
Xmlns: mx = "http://www.adobe.com/2006/mxml"
Xmlns: esri = "http://www.esri.com/2008/ags"
Layout = "absolute"
PageTitle = "Identify Features on the Map"
>
<Mx: Script>
<! [CDATA [
Import com. esri. ags. Graphic;
Import com. esri. ags. events. DrawEvent;
Import com. esri. ags. events. IdentifyEvent;
Import com. esri. ags. geometry. Geometry;
Import com. esri. ags. symbol. Symbol;
Import com. esri. ags. tasks. IdentifyParameters;
Import com. esri. ags. tasks. IdentifyResult;
Import com. esri. ags. toolbars. Draw;
Private function drawEndHandler (event: DrawEvent): void
{
Var geometry: Geometry = event. geometry;
Var identifyParams: IdentifyParameters = new
IdentifyParameters ();
IdentifyParams. returnGeometry = true;
IdentifyParams. tolerance = 3;
IdentifyParams. width = 600;
IdentifyParams. height = 550;
IdentifyParams. geometry = geometry;
IdentifyParams. layerOption =
IdentifyParameters. LAYER_OPTION_ALL;
IdentifyParams. mapExtent = map. extent;

IdentifyTask.exe cute (identifyParams );
}

Private function identifyCompleteHandler
(Event: IdentifyEvent): void
{
For each (var result: IdentifyResult in
Event. identifyResults)
{
MyGraphicsLayer. add (result. feature );
}
}
]>
</Mx: Script>
<! -- Draw ToolBar -->
<Esri: Draw id = "drawToolbar" map = "{map }"
GraphicsLayer = "{myGraphicsLayer}" drawEnd = "drawEndHandler (event)">
</Esri: Draw>
<! -- Identify Task -->
<Esri: IdentifyTask id = "identifyTask"
IdentifyComplete = "identifyCompleteHandler (event )"

Url = "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Special
Ty/ESRI_StatesCitiesRivers_USA/MapServer "/>
<Mx: Panel width = "100%" height = "100%">
<Mx: Button label = "Identify" click = "drawToolbar. activate
(Draw. MAPPOINT) "/>
<Esri: Map id = "map" width = "100%" height = "100%">
<Esri: ArcGISDynamicMapServiceLayer

Url = "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Special
Ty/ESRI_StatesCitiesRivers_USA/MapServer "/>
<Esri: GraphicsLayer id = "myGraphicsLayer"/>
</Esri: Map>
</Mx: Panel>
</Mx: Application>

Original address: http://bbs.esrichina-bj.cn/ESRI/viewthread.php? Tid = 35661 & extra = page % 3D4% 26amp % 3 Borderby % 3 Ddateline

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.