<?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" xmlns:esri="http://www.esri.com/2008/ags"> <fx:Script> <![CDATA[ import com.esri.ags.SpatialReference; import com.esri.ags.events.FeatureLayerEvent; import com.esri.ags.events.LayerEvent; import com.esri.ags.layers.supportClasses.FeatureCollection; import com.esri.ags.tasks.supportClasses.Query; protected function fl1_loadHandler(event:LayerEvent):void { var query:Query = new Query(); query.outSpatialReference = new SpatialReference(102100); query.where = "1 = 1"; fl1.queryFeatures(query); } protected function fl1_queryFeaturesCompleteHandler(event:FeatureLayerEvent):void { var featureCollection:FeatureCollection = new FeatureCollection(); featureCollection.featureSet = event.featureSet; featureCollection.layerDefinition = event.featureLayer.layerDetails; fl2.featureCollection = featureCollection; } ]]> </fx:Script> <fx:Declarations> <esri:FeatureLayer id="fl1" load="fl1_loadHandler(event)" queryFeaturesComplete="fl1_queryFeaturesCompleteHandler(event)" url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/EarthquakesFromLastSevenDays/MapServer/0"/> </fx:Declarations> <esri:Map id="map"> <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/> <esri:FeatureLayer id="fl2"/> </esri:Map> </s:Application>
You could create a FeatureCollection with a FeatureSet that gets its features from another layer's graphicProvider and the layerDefinition from the other layer's layerDetails property.
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.