Version 3.6
摘录地址: https://developers.arcgis.com/flex/guide/tutorial-query-your-data.htm
在本教程中,您将了解如何使用查询任务的工作,从一个ArcGIS服务查询数据。典型的情况是查询中涉及的过程的四个步骤:
总体代码片段
<?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"> <!-- 设置页面布局 --> <s:layout> <s:VerticalLayout gap="10" horizontalAlign="center" paddingBottom="20" paddingLeft="25" paddingRight="25" paddingTop="20"/> </s:layout> <fx:Script> <![CDATA[ import com.esri.ags.FeatureSet; import mx.controls.Alert; import mx.rpc.AsyncResponder; private function doQuery():void { queryTask.execute(query,new AsyncResponder(onResult,onFault)); function onResult(featureSet:FeatureSet,token:Object = null):void { // 在这个简单的实例中不需要写入代码,因为图形层是使用graphicProvider绑定到查询结果=“{queryTask.executeLastResult.features}” // graphicProvider="{queryTask.executeLastResult.features}" } function onFault(info:Object,token:Object = null):void { Alert.show(info.toString(),"Query Problem"); } } ]]> </fx:Script> <fx:Declarations> <!-- 美国区域层 --> <esri:QueryTask id="queryTask" showBusyCursor="true" useAMF="false" url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5"/> <esri:Query id="query" outSpatialReference="{myMap.spatialReference}" returnGeometry="true" text="{qText.text}"> <esri:outFields> <fx:String>MED_AGE</fx:String> <fx:String>POP2007</fx:String> </esri:outFields> </esri:Query> </fx:Declarations> <s:Panel height="60" backgroundColor="0xB2BFC6" title="查询层(搜索状态)"> <s:layout> <s:HorizontalLayout/> </s:layout> <s:TextInput id="qText" width="100%" enter="doQuery()" text="California"/> <s:Button label="搜索" click="doQuery()"/> </s:Panel> <esri:Map id="myMap"> <esri:extent> <esri:Extent xmax="-6815000" xmin="-14298000" ymax="7117000" ymin="2748000"> <esri:SpatialReference wkid="102100"/> </esri:Extent> </esri:extent> <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer"/> <esri:Graphicslayer id="myGraphicslayer" graphicProvider="{queryTask.executeLastResult.features}"/> </esri:Map> </s:Application>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。