// build the featurelayer var featureSet:FeatureSet = new FeatureSet(graphicCollection); var layerDetails:LayerDetails = new LayerDetails(); var featureLayer:FeatureLayer = new FeatureLayer(); featureLayer.featureCollection = new FeatureCollection(featureSet, layerDetails); //build the query based on a polygon I want to intesect with the features in the featurelayer var query:Query = new Query(); query.geometry = mypolygon; query.spatialRelationship = Query.SPATIAL_REL_INTERSECTS; query.outSpatialReference = spatialReference; //run the query featureLayer.selectFeatures(query, FeatureLayer.SELECTION_NEW,new AsyncResponder(onQueryResult2, onQueryFault2));
var layerName:String; if ( configXML ) { layerName = configXML.layer; } else { layerName = "Tickets"; } var ticketLayer:FeatureLayer = map.getLayer(layerName) as FeatureLayer; var queryTask:QueryTask = new QueryTask(ticketLayer.url); var queryTickets:Query = new Query(); // geom is the geometry object that the user draws on the map if ( geom != null ) { queryTickets.geometry = geom; queryTickets.spatialRelationship = Query.SPATIAL_REL_INTERSECTS; queryTickets.outSpatialReference = geom.spatialReference; } else { queryTickets.outSpatialReference = map.spatialReference; } var graph:GraphicsLayer = new GraphicsLayer(); graph.name = "testGeo"; map.addLayer(graph); //ticketLayer.queryFeatures(queryTickets, new AsyncResponder(onResult, onFault)); queryTask.execute(queryTickets, new AsyncResponder(onResult, onFault )); function onResult(featureSet:FeatureSet, token:XMLList = null):void { var tktSym:SimpleMarkerSymbol = new SimpleMarkerSymbol("triangle", 20, 0xFF0000); graph.symbol = tktSym; graph.graphicProvider = featureSet.features; } function onFault(info:Object, token:Object = null):void { }
var polygon:Polygon = new Polygon(); //This would be the user's created polygon. for(var i:int = 0; i<=graphicsLayer.numGraphics;i++){ if(!polygon.contains(MapPoint((graphicsLayer.graphicsProvider as Graphic).geometry)){ graphic.visible = false; }else{ graphic.visible = true; }; };
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.