• 关于querytask查询的问题; giser


    <?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" xmlns:renderers="com.esri.ags.renderers.*" >
     <fx:Declarations>
      <!-- 将非可视元素(例如服务、值对象)放在此处 -->
      <esri:QueryTask  url="http://gis/ArcGIS/rest/services/x/MapServer/13" useAMF="false" showBusyCursor="true" id="queryTask">
       
      </esri:QueryTask>
      <esri:Query   id="query" >
       <esri:outFields>
        <fx:String>NAME</fx:String>
       </esri:outFields>
      </esri:Query>
      <esri:ClassBreaksRenderer>
       <esri:ClassBreakInfo>
        <esri:SimpleFillSymbol id="rfill" alpha="0.5" color="red"/>
       </esri:ClassBreakInfo>
      </esri:ClassBreaksRenderer>
     </fx:Declarations>
     <fx:Script>
      <![CDATA[
       import com.esri.ags.FeatureSet;
       import com.esri.ags.Graphic;
       import com.esri.ags.SpatialReference;
       import com.esri.ags.geometry.Geometry;
       import com.esri.ags.geometry.MapPoint;
       import com.esri.ags.geometry.Polygon;
       import com.esri.ags.layers.GraphicsLayer;
       import com.esri.ags.symbols.PictureMarkerSymbol;
       
       import mx.controls.Alert;
       import mx.rpc.AsyncResponder;
       import mx.rpc.events.FaultEvent;
       
       private var myGraphicLayer:GraphicsLayer=new GraphicsLayer();
       private function doQuery():void
       {
          query.where="NAME like '%"+qText.text+"%'";
         
          query.returnGeometry=true;
        
          queryTask.execute(query,new AsyncResponder(OnResult,onFault));
       
       }
       
       
       private function OnResult(featureSet:FeatureSet,token:Object=null):void
       {
          
        
         var polygon:Polygon=new Polygon();
        polygon=featureSet.features[0].geometry;
        var graphic:Graphic=new Graphic();
        graphic.geometry=polygon;
        graphic.symbol=rfill;
        
        myGraphicLayer.clear();
        
        myGraphicLayer.add(graphic);
        mymap.extent=featureSet.features[0].geometry.extent;
        datagrid.dataProvider=featureSet.attributes;
        
        mymap.addLayer(myGraphicLayer);
        
        myGraphicLayer.graphicProvider=featureSet.features;
        //mymap.centerAt(featureSet.features[0].geometry);
        
        
        
       }
        private function onFault(info:Object, token:Object = null):void
       {
        Alert.show(info.toString(), "Query Problem");
       }
       
      ]]>
     </fx:Script>
     <esri:Map id="mymap">
      <esri:ArcGISDynamicMapServiceLayer url="http://gis/ArcGIS/rest/services/x/MapServer"/
     </esri:Map>
     
     <s:Panel height="60"
        backgroundColor="0xB2BFC6"
        title="Query a layer (search for a state)">
      <s:layout>
       <s:HorizontalLayout/>
      </s:layout>
      <s:TextInput id="qText"
          width="100%"
          enter="doQuery()"
          text="南京市"/>
      <s:Button click="doQuery()" label="Do Query"/>
     </s:Panel>
     <mx:DataGrid id="datagrid" bottom="20" width="200" height="150" horizontalCenter="0" />
     
    </s:Application>
     

  • 相关阅读:
    学习进度第三周
    四则运算3
    学习进度第二周
    单元测试
    四则运算2
    学习进度第一周
    四则运算1
    构建之法阅读笔记01
    linux: 讨论一下网络字节序--------大端与小端的差别
    linux编程:线程条件同步
  • 原文地址:https://www.cnblogs.com/xuchuansong/p/2728550.html
Copyright © 2020-2023  润新知