reproject map extent using geometry service
My corporate data is published in geographic coordinates (nad 83, decimal degrees) but my application is in web mercator. When I retrieve the featureset from the map server to set the extent I will need to do two things:
union all the returns
get the extent of the unioned returns, then re-project the extent to web mercator.
I am doing this in a workflow. Is there a sample or can anyone provide me the syntax for:
union the returns and get the extent
reproject the extent from geographic to web mercator using a geometry service.
Jeff
-
To union the contents of a featureSet:
1. Use a foreach loop to add each component graphic of the featureSet to a Collection<Graphic>
2. Use the Collection<Graphic> as input to the UnionTask, and put the results in a ESRI.ArcGIS.Client.Geometry.Geometry variable. (note: although a featureSet is a collection of Graphics, and the UnionTask appears to ask for a featureSet, it will not accept one. Yes, this is a bug.)
3. Your geometry variable can now give you the extent -- geometry.Extent
To reproject to Web Mercator:
?1. Create a new instance of the ESRI.ArcGIS.Client.Projection.WebMercator class. It needs to be initialized to a default value: new ESRI.ArcGIS.Client.Projection.WebMercator()
2. Now you can use it to reproject a geometry in geographic coordinates to WebMercator. Say you called your instance 'project' -- then the syntax would be project.FromGeographic(geometry). A ToGeographic method is also available.
0 -
Does anyone have a workflow example using projections, it would be very helpful in undestanding.
0
Please sign in to leave a comment.
Comments
2 comments