Select to view content in your preferred language

Cast ESRI.ArcGIS.Client.Geometry.Envelope to ESRI.ArcGIS.Client.Geometry

3074
3
09-16-2012 09:15 PM
JustinMadex
New Contributor
Hi,

I was looking for a way to cast/convert an Envelope object into a Geometry object so that I can write it to a feature service. I attempted to do a cast, but when writing the feature, I get an error from the ArcGIS server. Any ideas guys?

Thanks

Justin
0 Kudos
3 Replies
SanajyJadhav
Deactivated User
The following code works for me.

//This code is in Map's extent changed event.
 Envelope env = e.NewExtent;
ESRI.ArcGIS.Client.Geometry.Geometry poly = env.Extent as ESRI.ArcGIS.Client.Geometry.Geometry;


HTH.
0 Kudos
JustinMadex
New Contributor
Hey Sanjay,

Thanks for the reply. I was able to cast it to a geometry object successfully, but if I add that object to a Graphic object and try to write that to a feature service, it will fail. Do you know if its possible to write an extent as the geometry component of a feature?

Thanks

Justin
0 Kudos
SanajyJadhav
Deactivated User
Can you put your code here?

I am not sure I have understood your requirement correctly.I think your are adding a new feature to the layer in the feature service, right?And you want to set the Geometry property of this feature by the envelope ( some extent ).

Are you following the approach given below?


Graphic g = new Graphic;
g.Geometry = envelope as Geometry;
featrueLayer.Graphics.Add(g);

0 Kudos