加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Flex开发ArcGIS问题集锦九:怎样使用QueryTask执行空间查询和属性

发布时间:2020-12-15 04:16:39 所属栏目:百科 来源:网络整理
导读:? ? ? ? ? ? ? ? ? ? ?? ? Flex开发ArcGIS问题集锦九:怎样使用QueryTask执行空间查询和属性查询 代码 ?xml version="1.0" encoding="utf-8"?s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:esri=

? ? ? ? ? ? ? ? ? ? ???Flex开发ArcGIS问题集锦九:怎样使用QueryTask执行空间查询和属性查询

代码

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
			   xmlns:mx="library://ns.adobe.com/flex/mx"
			   xmlns:esri="http://www.esri.com/2008/ags"
			   xmlns:s="library://ns.adobe.com/flex/spark"
			   pageTitle="Query Task (with a map)">
	<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 com.esri.ags.Graphic;
			import com.esri.ags.components.LabelDataRenderer;
			
			import mx.controls.Alert;
			import mx.core.UIComponent;
			import mx.rpc.AsyncResponder;
			
			private function doQuery():void
			{				
				
				query.where = "wellName like '%" + qText.text + "%'";
				queryTask.url = "http://SDRJ-WX/arcgis/rest/services/sample/MapServer/0"; 
				queryTask.execute(query,new AsyncResponder(onResult,onFault));
				function onResult(featureSet:FeatureSet,token:Object = null):void
				{			
					myGraphicsLayer.graphicProvider = featureSet.features;	
					datagrid.dataProvider = featureSet.attributes;
				}
				function onFault(info:Object,token:Object = null):void
				{
					Alert.show(info.toString(),"Query Problem");
				}
				
			}
		]]>
	</fx:Script>
	
	<fx:Declarations>
		<!--第一步:实例化QueryTask-->
		<esri:QueryTask id="queryTask" showBusyCursor="true"
						url="http://SDRJ-WX/arcgis/rest/services/sample/MapServer/0"/>
		<esri:Query id="query"
					outSpatialReference="{myMap.spatialReference}"
					returnGeometry="true">
			<esri:outFields>
				<fx:String>wellName</fx:String>
				<fx:String>wellCode</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="三星"/>
		<s:Button click="doQuery()" label="搜索"/>
	</s:Panel>
	
	<esri:Map id="myMap" width="627" height="416">
		<esri:extent>
			<esri:Extent xmin="-504.498455000157" ymin=" -10490.0680449995"
						 xmax="10500.1491550003"  ymax="507.490945000109">
				<esri:SpatialReference wkid="2379"/>
			</esri:Extent>
		</esri:extent>
		<!--使用sample地图-->
		<esri:ArcGISDynamicMapServiceLayer 
			url="http://SDRJ-WX/arcgis/rest/services/sample/MapServer"/>
		<esri:GraphicsLayer id="myGraphicsLayer"/>
	</esri:Map>
	<mx:DataGrid id="datagrid" bottom="20" width="200" height="150" horizontalCenter="0" />
</s:Application>

效果


到此结束!!!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读