getting the mapextent of multiple features
I have the workflow for getting a single feature's mapextent working, but what about feature sets that include multiple polygons? I heard this was "sticky" can anyone provide a good sample of this?
So if I return a featureset from a query and it consists of many polygons, can I get the extent of the entire featureset not just the "first" as in this sample code:
geos.first().Extent.Expand(1.25)
Is there a linq code for all instead of first?
Jeff
-
You certainly can do this, but it is not as straight forward. And unfortunately there is no .All() that corresponds to .First(), as we get this from IList<T>, which has no geographical awareness.
Basically, take your featureset, and do a foreach feature in featureset --> AddToCollection<Graphic> and assign them all to a Collection<Graphic> variable. This variable needs a default value when you create it (look on the right hand pane), and this value is 'New Collection(Of Graphic)'.
Now that you have a collection of graphics, you can put them in an ESRI Union Task, and get out a single geometry. Then you can set the extent to this:
geometry.Extent.Expand(1.25)
If this is not clear, I'll post the example tomorrow.
0 -
Jonathan,
An example workflow would be lovely (xaml file). Now if its a graphic that we get the extent for and zoom to, can this graphic be displayed and assigned colors, labels and etc.? that would fit in with my workflow nicely.
Jeff
0 -
Here's the one I was talking about above. Run it on our sample Charlotte map, and it should select the two uppermost zip codes, and zoom to them with a buffer.
(https://support.geocortex.com/Data/Sites/1/media/forumfiles/multiselectandzoom.zip) /Data/Sites/1/media/forumfiles/multiselectandzoom.zip
You should be able to do things like adding markup with the 'Run External Command' functionality in Workflow Designer. You can use this to run any native Silverlight Viewer command on the client. For example, the command 'AddMarkup' takes a geometry as input and will then draw it on the map.
0 -
I have a question. I see that you do a query fetaures then you do a select features. Does the add to collection graphic require geocortex features instead of arcserver features? I am getting an error of failure to initialize collection.
J
0 -
Jonathan--
thanks for all your help. it is appreciated.
I have it working in the charlotte service, so now I am slogging through our service. I see where the default should be set. They took our server for the rest of the day, but I will keep on tomorrow.
J
0 -
Hi
Just tried out the multiselectandzoom example but for some reason it stops when executing the SetMapExtent, error message:
Unable to serialize object: The calling thread cannot access this object because a different thread owns it.
Any help on how to get past this error msg, would be great.
-Sigurd
0 -
ah, it now runs as it should, just had to move the SetMapExtent outside the Sequence.
Really appreciated this example workflow, thank you :-)
-Sigurd
0 -
I encountered the same issue as Sigurd recently. The Collection<Graphic>, graphic, is failing to serialize when the workflow data gets to the client.
By the time we reach the SetMapExtent activity, we no longer need the data in the collection. So, right before SetMapExtent, add a ClearCollection<T> activity with TypeArgument= ESRI.ArcGIS.Client.Graphic and Collection= graphic. The "Unable to serialize object" error should go away.
0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
8 kommentarer