Select to view content in your preferred language

Change outfields and esri:query layer based on map scale or LOD?

624
2
07-20-2011 09:48 AM
JohnMcNally
Emerging Contributor
I am using a tiledmapservicelayer to display a map and a querytask to return a geo id and polygon from the service and send the id to a coldfusion function in order fill datagrid/charts with related data.

I was wondering if it was possible to change the query layer and outfields base on what scale or what LOD the user was looking at. essentially I want to change the geographies returned as the user zooms in. I am new to flex/arcgis and I am not sure if I am going about reaching this goal the right way. below is a portion of my code. If someone could point me in the right direction it would be appreciated.

currently this works for one geography layer.

[Bindable] public var querylayer:Number = 4;
[Bindable] public var code:String = "CSDUID";
     
      private function fault(evt:FaultEvent):void {
                  Alert.show(evt.fault.message);                               
            }
      private function result(evt:ResultEvent):void {
                  GEODATAGRID.dataProvider = evt.result;
           }
                      
      public function onMapClick(event:MapMouseEvent):void
            {
                query_1.geometry = event.mapPoint;
                queryTask_1.execute(query_1);              
            }
      private function onQueryExecuteComplete(event:QueryEvent):void
            {
                myGraphicsLayer.clear();
                graphicsLayer.clear();                              
                var fset:FeatureSet = event.featureSet;
                for each (var graphic:Graphic in fset.features)
                {
                    graphic.symbol = sfs;
                    graphic.infoWindowRenderer = myInfoWindowRenderer;
                    graphicsLayer.add(graphic);
                    var GEOCODE:Object = new Object();
                    GEOCODE = graphic.attributes
;

                    getgeodata.geo(GEOCODE);
                }
            }

<mx:RemoteObject
id="getgeodata"
destination="ColdFusion"
showBusyCursor="true"
source="mcnajoh.ARCGIS_MAP.components.getgeodata"
fault="fault(event)" result="result(event)">
<mx:method name="result" result="result(event)">
</mx:method>
</mx:RemoteObject> 

<!-- Symbol for Query Result as Polygon -->
      
<esri:SimpleFillSymbol id="sfs" alpha="0.4" color="0xF8705D">
<esri: outline>
  <esri:SimpleLineSymbol style="solid" color="0x000000" width="2">
  
  </esri:SimpleLineSymbol>
</esri: outline>
</esri:SimpleFillSymbol>

<esri:QueryTask id="queryTask_1" url="http://c192991:8399/arcgis/rest/services/map/NS_CD-CSD_GDB/MapServer/{querylayer}" executeComplete="onQueryExecuteComplete(event)"/>           
<esri:Query id="query_1" returnGeometry="true">
          
<esri: outFields>
<mx:String>{code}</mx:String>
</esri: outFields>
</esri:Query>

<mx: DataGrid id="GEODATAGRID"
  visible="{queryTask_1.executeLastResult != null}"
  dataProvider="{getgeodata.geo}"
  scroll="true" width="100%" height="100">
<mx:columns>
<mx: DataGridColumn headerText="CSD NAME" dataField="CSDNAME"/>
<mx: DataGridColumn headerText="CSD Type" dataField="CSDTYPE"/>
</mx:columns>
</mx: DataGrid>

<esri:Map id="canmap"
logoVisible="false"
height="100%" width="100%" top="150" backgroundColor="0x467699"
mapClick="onMapClick(event)"
keyboardNavigationEnabled="true">
<esri:lods>
<esri:LOD id="PROV" level="1" resolution="793.7515875031751" scale="3000000.0"/>
<esri:LOD id="PROV_1" level="2" resolution="529.1677250021168" scale="2000000.0"/>
<esri:LOD id="CD" level="3" resolution="264.5838625010584" scale="1000000.0"/>
<esri:LOD id="CD_1" level="4" resolution="132.2919312505292" scale="500000.0"/>
<esri:LOD id="CSD" level="5" resolution="66.1459656252646" scale="250000.0"/>
<esri:LOD id="CSD_2" level="6" resolution="26.458386250105836" scale="100000.0"/>
<esri:LOD id="CSD_3" level="7" resolution="13.229193125052918" scale="50000.0"/>
</esri:lods>

<esri:extent>
<esri:Extent xmin="7691642.342458517" ymin="1216427.9388237474" xmax="9279233.002318736" ymax="1876661.047369435">
   <esri:SpatialReference wkid="3347">
   
   </esri:SpatialReference>
</esri:Extent>
</esri:extent>
         <esri:ArcGISTiledMapServiceLayer url="http://c192991:8399/arcgis/rest/services/map/NS_CD-CSD_GDB/MapServer">
         </esri:ArcGISTiledMapServiceLayer>
         <esri:GraphicsLayer id="myGraphicsLayer" symbol="{sfs}"/>
         <esri:GraphicsLayer id="graphicsLayer"/>
         
</esri:Map>
<mx:TraceTarget>
</mx:TraceTarget>

</mx:Application>

Thanks.
Tags (2)
0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus
John,

   In you onMapClick function you can check the Map.level and adjust the querylayer and code vars before you execute the queryTask.
0 Kudos
JohnMcNally
Emerging Contributor
That did the trick! Thanks very much for your quick response.
0 Kudos