<?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" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"> <fx:Script> <![CDATA[ import com.esri.ags.layers.ArcGISDynamicMapServiceLayer; import mx.collections.ArrayCollection; protected function MySlider_changeHandler(event:Event):void { var x:Number = Math.round(MySlider.value - .5); var y:Number = MySlider.value; var z:Number = x + 1; var lyr1:ArcGISTiledMapServiceLayer = MyMap.layers; var lyr2:ArcGISTiledMapServiceLayer = MyMap.layers ; lyr1.alpha = y - x; lyr2.alpha = 1 - (y - x); } ]]> </fx:Script> <fx:Declarations> </fx:Declarations> <esri:Map id="MyMap"> <esri:ArcGISTiledMapServiceLayer id="l0" url="http://server1/ArcGIS/rest/services/Basemaps/map1/MapServer" alpha="0"/> <esri:ArcGISTiledMapServiceLayer id="l1" url="http://server1/ArcGIS/rest/services/Basemaps/map2/MapServer" alpha="0"/> <esri:ArcGISTiledMapServiceLayer id="l2" url="http://server1/ArcGIS/rest/services/Basemaps/map3/MapServer" alpha="0"/> <esri:ArcGISTiledMapServiceLayer id="l3" url="http://server1/ArcGIS/rest/services/Basemaps/map4/MapServer" alpha="0"/> <esri:ArcGISTiledMapServiceLayer id="l4" url="http://server1/ArcGIS/rest/services/Basemaps/map5/MapServer" alpha="0"/> </esri:Map> <s:Panel id="aPanel" title="Slider" height="100" width="500" bottom="20" horizontalCenter="0"> <s:HSlider width="90%" id="MySlider" minimum="0" maximum="3.99" stepSize=".05" value="0" change="MySlider_changeHandler(event)" /> </s:Panel> </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" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"> <fx:Script> <![CDATA[ import com.esri.ags.layers.Layer; import mx.events.FlexEvent; private var baseLayers:Vector.<Layer> = new Vector.<Layer>(); protected function MySlider_changeHandler(event:Event):void { var currentValue:Number = event.currentTarget.value; var floorValue:Number = Math.floor(event.currentTarget.value); trace("Current Value: " + currentValue + " Floor Value: " + floorValue); //set the alpha if it is les than the the max value if (currentValue < event.currentTarget.maximum) { baseLayers[floorValue].alpha = currentValue - floorValue; trace("Alpha (Current - Floor): " + (currentValue - floorValue)); } //set the alpha for the previous layer one OR the last layer baseLayers[floorValue - 1].alpha = 1 - (currentValue - floorValue); trace("Previous Alpha: " + (1 - (currentValue - floorValue))); //reset the alpha to zero for the layers that are not being merged. //This is needed to cater for a track click for (var i:int = 0; i < baseLayers.length; i++) { if (i > floorValue || i < floorValue - 1) { baseLayers.alpha = 0; } } } /* Load the layers into the vector. Layers can be loaded by any method. This method adds all ArcGISTiledMapServiceLayer's that are in the map. You could hard code the layers to add. You could also use an xml file or webservice etc. */ protected function MyMap_creationCompleteHandler(event:FlexEvent):void { for each (var layer:ArcGISTiledMapServiceLayer in MyMap.layers) { baseLayers.push(layer); } MySlider.minimum = 1; MySlider.maximum = baseLayers.length; MySlider.value = 0; } ]]> </fx:Script> <fx:Declarations> </fx:Declarations> <esri:Map id="MyMap" creationComplete="MyMap_creationCompleteHandler(event)"> <esri:ArcGISTiledMapServiceLayer id="l0" url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" alpha="1"/> <esri:ArcGISTiledMapServiceLayer id="l1" url="http://server.arcgisonline.com/ArcGIS/rest/services/NGS_Topo_US_2D/MapServer" alpha="0"/> <esri:ArcGISTiledMapServiceLayer id="l2" url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer" alpha="0"/> <esri:ArcGISTiledMapServiceLayer id="l3" url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" alpha="0"/> <esri:ArcGISTiledMapServiceLayer id="l4" url="http://server.arcgisonline.com/ArcGIS/rest/services/NGS_Topo_US_2D/MapServer" alpha="0"/> </esri:Map> <s:Panel id="aPanel" title="Slider" height="100" width="500" bottom="20" horizontalCenter="0"> <s:layout> <s:VerticalLayout paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10"/> </s:layout> <s:HSlider width="100%" id="MySlider" minimum="1" maximum="5" stepSize=".01" value="0" change="MySlider_changeHandler(event)" /> </s:Panel> </s:Application>
protected function MyMap_creationCompleteHandler(event:FlexEvent):void { baseLayers.push(yourBingLayer); MySlider.minimum = 1; MySlider.maximum = baseLayers.length; MySlider.value = 0; }
//Manually add to 'baseLayers' baseLayers.push(l5); baseLayers.push(l6); <esri:Map id="MyMap" creationComplete="MyMap_creationCompleteHandler(event)"> <esri:ArcGISTiledMapServiceLayer id="l0" url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" alpha="1"/> <esri:ArcGISTiledMapServiceLayer id="l1" url="http://server.arcgisonline.com/ArcGIS/rest/services/NGS_Topo_US_2D/MapServer" alpha="0"/> <esri:ArcGISTiledMapServiceLayer id="l2" url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer" alpha="0"/> <esri:ArcGISTiledMapServiceLayer id="l4" url="http://server.arcgisonline.com/ArcGIS/rest/services/NGS_Topo_US_2D/MapServer" alpha="0"/> <esri:ArcGISDynamicMapServiceLayer id="l5" url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer" alpha="0" /> <esri:FeatureLayer id="l6" definitionExpression="TYPE='city' AND POP1990 > 50000" outFields="[CITY_NAME,CAPITAL,DIVORCED,POP1990,MALES,FEMALES]" url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/0" alpha="0"> <esri:renderer> <esri:UniqueValueRenderer attribute="CAPITAL"> <esri:defaultSymbol> <esri:SimpleMarkerSymbol color="0xCCCCCC" size="12" style="x"/> </esri:defaultSymbol> <esri:UniqueValueInfo value="Y"> <esri:symbol> <esri:CompositeSymbol> <!-- Star in circle --> <esri:SimpleMarkerSymbol color="0xFF0000" size="22" style="circle"/> <esri:SimpleMarkerSymbol color="0xFFFFFF" size="20" style="triangle"/> <esri:SimpleMarkerSymbol angle="180" color="0xFFFFFF" size="20" style="triangle"/> </esri:CompositeSymbol> </esri:symbol> </esri:UniqueValueInfo> <esri:UniqueValueInfo value="N"> <esri:symbol> <esri:SimpleMarkerSymbol color="0xFF0000" size="18" style="diamond"/> </esri:symbol> </esri:UniqueValueInfo> </esri:UniqueValueRenderer> </esri:renderer> </esri:FeatureLayer> </esri:Map>