Select to view content in your preferred language

Selected Feature Geometry error for a zoom to selected functionality

1013
4
01-24-2011 11:44 AM
DeeptiVB
Emerging Contributor
Hello,

I am a newbie with Silverlight/ArcGIS server development. I am developing a web app in ArcGIS Server 10, Silverlight 3, VS 2010. This is an upgrade to an app which was working in ArcGIS 9.x, VS 2008, Silverlight 2.

I am accessing an SDE layer and trying to zoom into the record that user inputs in an autocomplete box. It gets the selected feature but SelectedFeature.Geometry comes back as nothing, when it is expecting polygon geometry.

I have the map service and the geometry service running on the server, tabular queries are coming back fine, it is the spatial queries which do not work. If I change the dynamic map service to my old map service(ArcGIS 9.x,...), the spatial queries also work perfectly.

Has this got anything to do with using SDE layer as the spatial layer? I cannot figure out why the geometry of the selected feature comes back as nothing from the new service. Something to do with Silverlight/ArcGIS 10 upgrade I s'pose. Found a thread, which explains the same problem as mine, but it does not seem to have addressed the geometry part? Any help is appreciated.

Calling all experts

TIA

-Deepti

Dim featureSet As FeatureSet = args.FeatureSet

If featureSet IsNot Nothing AndAlso featureSet.Features.Count > 0 Then
Dim selectedFeature As Graphic = featureSet.Features(0)

Dim selectedFeatureExtent As ESRI.ArcGIS.Client.Geometry.Envelope = selectedFeature.Geometry.Extent

     Dim expandPercentage As Double = 300
     Dim widthExpand As Double = selectedFeatureExtent.Width * (expandPercentage / 100)
     Dim heightExpand As Double = selectedFeatureExtent.Height * (expandPercentage / 100)

 Dim displayExtent As New ESRI.ArcGIS.Client.Geometry.Envelope(selectedFeatureExtent.XMin - (widthExpand / 2), selectedFeatureExtent.YMin - (heightExpand / 2), selectedFeatureExtent.XMax + (widthExpand / 2), selectedFeatureExtent.YMax + (heightExpand / 2))

 MyMap.ZoomTo(displayExtent)

0 Kudos
4 Replies
DeeptiVB
Emerging Contributor
Ok, solved it myself. The geometry type of the features in the featureset was coming back null in ArcGIS Server 10. It was coming back as Polygon when the map service was in ArcGIS Server 9. So while upgrading the web map app to 10, I had to explicitly state in code that query.returnGeometry = true. Works now.
0 Kudos
DeeptiVB
Emerging Contributor
Hi...I set ReturnGeometry=true, but it doesn't work too. my toolkit version is 1.2, is your toolkit version 2.1?

Mine is 2.1
0 Kudos
DeeptiVB
Emerging Contributor
Hi...I set ReturnGeometry=true, but it doesn't work too. my toolkit version is 1.2, is your toolkit version 2.1?

I had this problem again and I found that in the mxd you use to create your webservice, if you turn off the shape column of the layers you run the query on, selectedfeature.geometry comes back as null. Keep the shape column on if you are doing anything with geometry.

Also make sure you have Geometry service running on your web server.
0 Kudos
TanuHoque
Esri Regular Contributor
... if you turn off the shape column of the layers you run the query on, selectedfeature.geometry comes back as null...


Just so you know, that is expected behavior. We a field is invisible in source map (mxd/msd), query result does not include values from that invisible field.
0 Kudos