<?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="Map Extent and Mouse Coordinates"
creationComplete="combobox()">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
private function combobox():void
{
var comboArray:ArrayCollection = new ArrayCollection();
comboArray = comm_layer.layerInfos.Communities_Places //the specific layer in the map service
cmb.dataProvider = comboArray;
cmb.labelField = comboArray.comm_name_ //field within the Communities_Places layer
}
]]>
</fx:Script>
<s:layout>
<s:VerticalLayout paddingTop="6"/>
</s:layout>
<s:HGroup>
<s:ComboBox id="cmb" right="250"/>
</s:HGroup>
<esri:Map id="myMap">
<esri:extent>
<esri:Extent xmin="-13338986.2116637" ymin="3926661.77417242" xmax="-13002755.460699" ymax="4152028.76378653">
<esri:SpatialReference wkid="3857"/>
</esri:Extent>
</esri:extent>
<esri:ArcGISDynamicMapServiceLayer id="comm_layer" url="http://10.2.8.73/ArcGIS/rest/services/ZNET_Public/city_maskForExtent/MapServer"/>
</esri:Map>
</s:Application>
<?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">
<fx:Script>
<![CDATA[
import com.esri.ags.Graphic;
import com.esri.ags.events.MapEvent;
import com.esri.ags.events.QueryEvent;
import com.esri.ags.geometry.Extent;
import com.esri.ags.tasks.supportClasses.Query;
import mx.collections.ArrayList;
import spark.events.IndexChangeEvent;
protected function map_loadHandler(event:MapEvent):void
{
var query:Query = new Query();
query.outFields = [ "STATE_NAME" ];
query.outSpatialReference = map.spatialReference;
query.returnGeometry = true;
query.where = "1=1";
queryTask.execute(query);
}
protected function queryTask_executeCompleteHandler(event:QueryEvent):void
{
ddList.dataProvider = new ArrayList(event.featureSet.features);
}
protected function ddListLabelFunction(item:Graphic):String
{
return item.attributes["STATE_NAME"];
}
protected function ddList_changeHandler(event:IndexChangeEvent):void
{
var stateExtent:Extent = Graphic(ddList.selectedItem).geometry.extent;
map.extent = stateExtent
// make sure the whole extent is visible
if (!map.extent.contains(stateExtent))
{
map.level--;
}
}
]]>
</fx:Script>
<fx:Declarations>
<esri:QueryTask id="queryTask"
executeComplete="queryTask_executeCompleteHandler(event)"
showBusyCursor="true"
url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5"
useAMF="false"/>
</fx:Declarations>
<s:controlBarContent>
<s:DropDownList id="ddList"
width="200"
change="ddList_changeHandler(event)"
labelFunction="ddListLabelFunction"
prompt="Choose a state to zoom to"/>
</s:controlBarContent>
<esri:Map id="map" load="map_loadHandler(event)">
<esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
</esri:Map>
</s:Application>
<?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="Map Extent and Mouse Coordinates"
creationComplete="combobox()">
<fx:Script>
<![CDATA[
import com.esri.ags.FeatureSet;
import com.esri.ags.Graphic;
import com.esri.ags.events.QueryEvent;
import com.esri.ags.tasks.QueryTask;
import com.esri.ags.tasks.supportClasses.Query;
import com.esri.ags.utils.GraphicUtil;
import mx.collections.ArrayCollection;
private function combobox():void
{
var comboQueryTask:QueryTask = new QueryTask();
comboQueryTask.url = "http://10.2.8.73/ArcGIS/rest/services/ZNET_Public/city_mask/MapServer/0";
comboQueryTask.useAMF = false;
var comboQuery:Query = new Query();
comboQuery.returnGeometry = true;
comboQuery.where = "1=1";
comboQuery.outFields = ["CITY_COMM_"];
comboQuery.outSpatialReference = myMap.spatialReference;
comboQueryTask.execute(comboQuery);
comboQueryTask.addEventListener(QueryEvent.EXECUTE_COMPLETE, onQueryComplete);
}
private var commExtent:Extent = new Extent();
private function onQueryComplete(event:QueryEvent):void
{
var featureSet:FeatureSet = event.featureSet;
var results:ArrayCollection = new ArrayCollection();
for each (var graphic:Graphic in featureSet.features)
{
var fieldValue:String = graphic.attributes["CITY_COMM_"].toString();
results.addItem({label: fieldValue, data: graphic});
}
cmb.labelField = "label";
cmb.dataProvider = results;
var graphicsExtent:Extent = GraphicUtil.getGraphicsExtent(featureSet.features);
commExtent = graphicsExtent;
}
private function change():void
{
var extent2:Extent = Graphic(cmb.selectedItem).geometry.extent;
myMap.extent = extent2;
}
]]>
</fx:Script>
<s:layout>
<s:VerticalLayout paddingTop="6"/>
</s:layout>
<s:HGroup>
<s:ComboBox id="cmb" right="250" change="change()" width="350" selectedItem="{{label:'Select Your Community'}}"/>
</s:HGroup>
<esri:Map id="myMap">
<esri:extent>
<esri:Extent xmin="-13338986.2116637" ymin="3926661.77417242" xmax="-13002755.460699" ymax="4152028.76378653">
<esri:SpatialReference wkid="3857"/>
</esri:Extent>
</esri:extent>
<esri:ArcGISDynamicMapServiceLayer id="comm_layer" url="http://10.2.8.73/ArcGIS/rest/services/ZNET_Public/city_maskForExtent/MapServer"/>
</esri:Map>
</s:Application>
<layer> <layerurl>http://gis.rksk.dk/ArcGIS/rest/services/AdresseLokalplan/MapServer/0</layerurl> <layeroutfield>ADR_NR_POST</layeroutfield> <layerzoomscale>1500</layerzoomscale> </layer>
var lyrList:XMLList = configXML..layer;
for (var i:int = 0; i < lyrList.length(); i++)
{
layerURL = lyrList.layerurl;
layerOutField = lyrList.layeroutfield;
layerZoomScale = lyrList.layerzoomscale;
var comboQueryTask:QueryTask = new QueryTask();
comboQueryTask.url = layerURL;
comboQueryTask.useAMF = false;
var comboQuery:Query = new Query();
comboQuery.returnGeometry = true;
comboQuery.where = "1=1";
comboQuery.outFields = [layerOutField];
comboQuery.outSpatialReference = map.spatialReference;
comboQueryTask.execute(comboQuery);
comboQueryTask.addEventListener(QueryEvent.EXECUTE_COMPLETE, onQueryComplete);
}
private function onQueryComplete(event:QueryEvent):void
{
var featureSet:FeatureSet = event.featureSet;
for each (var graphic:Graphic in featureSet.features)
{
var fieldValue:String = graphic.attributes[layerOutField].toString();
results.addItem({label: fieldValue, data: graphic});
}
var graphicsExtent:Extent = GraphicUtil.getGraphicsExtent(featureSet.features);
commExtent = graphicsExtent;
}