identifyTask,属性:concurrency:并行执行的设定(last,single,multi)                 

                     url:指定的是一个图层的MapServer

 identifyTask查询:identifyParams.geometry = event.mapPoint;  

                           identifyParams.tolerance = 3;//公差

                           identifyTask.execute(identifyParams, new AsyncResponder(myResultFunction, myFaultFunction, clickGraphic));

           查询结果:返回的结果只有一个graphic

                  var result:IdentifyResult = results[0];

                   var resultGraphic:Graphic = result.feature;

    I查询,最常用的geometry就是一个点。

<?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:esri="http://www.esri.com/2008/ags"
pageTitle="Identify Features on the Map">
<!--
This sample shows how to identify features with a MapClick and the Identify task.

The IdentifyParameters designate which layers are being identified.
Identify operations can potentially return a lot of information
depending on the number of layers being identified and a given tolerance.
The tolerance is the number of pixels a feature is allowed to lie away
from the clicked point in order to be counted as a result.

In this sample, when user clicks the map, an "Identify" task is executed.

When the task finishes executing, the executeCompleteHandler function loops
through the features in the IdentifyResult and adds them to the map.
-->
<fx:Script>
<![CDATA[
import com.esri.ags.Graphic;
import com.esri.ags.events.MapMouseEvent;
import com.esri.ags.geometry.Geometry;
import com.esri.ags.symbols.InfoSymbol;
import com.esri.ags.tasks.supportClasses.IdentifyParameters;
import com.esri.ags.tasks.supportClasses.IdentifyResult;

import mx.controls.Alert;
import mx.rpc.AsyncResponder;

[Bindable]private var lastIdentifyResultGraphic:Graphic;

private function mapClickHandler(event:MapMouseEvent):void
{
clickGraphicsLayer.clear();

var identifyParams:IdentifyParameters = new IdentifyParameters();
identifyParams.returnGeometry = true;
identifyParams.tolerance = 3;
identifyParams.width = myMap.width;
identifyParams.height = myMap.height;
identifyParams.geometry = event.mapPoint;
identifyParams.mapExtent = myMap.extent;
identifyParams.spatialReference = myMap.spatialReference;

var clickGraphic:Graphic = new Graphic(event.mapPoint, clickPtSym);
clickGraphicsLayer.add(clickGraphic);

identifyTask.execute(identifyParams, new AsyncResponder(myResultFunction, myFaultFunction, clickGraphic));
}

private function myResultFunction(results:Array, clickGraphic:Graphic = null):void
{
if (results && results.length > 0)
{
var result:IdentifyResult = results[0];
var resultGraphic:Graphic = result.feature;
switch (resultGraphic.geometry.type)
{
case Geometry.MAPPOINT:
{
resultGraphic.symbol = smsIdentify;
break;
}
case Geometry.POLYLINE:
{
resultGraphic.symbol = slsIdentify;
break;
}
case Geometry.POLYGON:
{
resultGraphic.symbol = sfsIdentify;
break;
}
}
lastIdentifyResultGraphic = resultGraphic;

// update clickGraphic (from mouse click to returned feature)
clickGraphic.symbol = new InfoSymbol(); // use default renderer
clickGraphic.attributes = resultGraphic.attributes;
}
}

private function myFaultFunction(error:Object, clickGraphic:Graphic = null):void
{
Alert.show(String(error), "Identify Error");
}
]]>
</fx:Script>

<fx:Declarations>
<!-- Symbol for where the user clicked -->
<esri:SimpleMarkerSymbol />
</esri:Map>

</s:Application>

FindTask的url是MapServer.

 FindTask查询:通过对FindParameters的searchText进行字符匹配来查询。     

           searchText展示的是图层的展示字段。      

             findTask.execute(myFindParams);        

    返回:数组。     

           findTask.executeLastResult

<?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"
xmlns:esri="http://www.esri.com/2008/ags"
pageTitle="Find features in Map Layers">
<!--
This sample shows how to search the data using the find task:

The FindParameters designate which layers and fields will be searched.
If multiple layers contain the same field name (for example "NAME")
both fields will be searched.

Note that in this example returnGeometry is set to true so that the results
can be displayed on the map.

The searchText of the FindParameters is what the task will search for.
This text comes from the input box and is sent to the execute function when
the user click the Find button. This line executes the task:
findTask.execute(myFindParams);

When the task finishes executing, the executeCompleteHandler function loops
through the array of graphics in the FindResult and adds each graphic to the map.

The datagrid at the bottom gets its content directly from the task:
dataProvider="{findTask.executeLastResult}"
-->

<s:layout>
<s:VerticalLayout horizontalAlign="center"/>
</s:layout>

<fx:Script>
<![CDATA[
import com.esri.ags.Graphic;
import com.esri.ags.events.FindEvent;
import com.esri.ags.geometry.Geometry;

private function doFind():void
{
findTask.execute(myFindParams);
}

private function executeCompleteHandler(event:FindEvent):void
{
myGraphicsLayer.clear();
var graphic:Graphic;
resultSummary.text = "Found " + event.findResults.length + " results.";
var resultCount:int = event.findResults.length;
for (var i:Number = 0; i < resultCount; i++)
{
graphic = event.findResults[i].feature;
graphic.toolTip = event.findResults[i].foundFieldName + ": " + event.findResults[i].value;

switch (graphic.geometry.type)
{
case Geometry.MAPPOINT:
{
graphic.symbol = smsFind;
break;
}
case Geometry.POLYLINE:
{
graphic.symbol = slsFind;
break;
}
case Geometry.POLYGON:
{
graphic.symbol = sfsFind;
break;
}
}
myGraphicsLayer.add(graphic);
}
}
]]>
</fx:Script>

<fx:Declarations>
<!-- Symbol for Find Result as Polyline -->
<esri:SimpleLineSymbol />
</mx:columns>
</mx:DataGrid>
</mx:VDividedBox>

</s:Application>

 

相关文章:

  • 2021-07-08
  • 2019-08-02
  • 2021-06-30
  • 2022-12-23
  • 2022-12-23
  • 2022-03-04
  • 2021-07-27
  • 2021-07-12
猜你喜欢
  • 2021-05-26
  • 2021-10-20
  • 2021-08-23
  • 2021-07-09
  • 2022-03-03
  • 2022-02-08
  • 2021-08-01
相关资源
相似解决方案