Question on comparing FeatureSets
I have a polygon layer and a polyline layer in my mapservice and some polylines intersect the polygons. So all I need to do is show each of those polygons highlighted on the map. I may be making this too hard but I created two querytask in my workflow (one for the polyline layer and the other for the polygon layer) and using the two FeatureSets I guess I would need to loop through the polygon layer featureset comparing each polygon to each polyline feature featureset and add it to a collection of some sort. If this is the only way to accomplish this, then I'm having trouble creating the For Each Loops. What type of For Each loop do I need to setup, a graphic For Each loop?
-
Thoughts anyone? Sorry, I'm stumped.. If I need to approach this in my algorithm above then how do I get a geometry from a Featureset? Would I need to loop through the FeatureSet by feature and store the geometry in a collection?
Any ideas would be greatly appreacited.
Best regards,
0 -
If you wish to create a FeatureSet of all the polygons that are intersected by polylines, the easiest way would be to use a Query Task to query the polygon layer, and give it a polyline Geometry as the input search parameter (you can use either a Where clause _or_ a Geometry as input to a query).
If you have a FeatureSet containing polylines, and you are wondering how to get the Geometry from this, use a Union Task. This will take an entire FeatureSet as input, and give you a single Geometry to use as input to the Query Task.
Then you can take the output FeatureSet, and use Select Features (do _not_ provide a collection name) to highlight them on the map. No ForEach loops required.
0 -
You are the man Jonathan, that worked.
Thanks.
0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
3 Kommentare