Select Features from ArcGISDynamicMapServiceLayer

5034
9
05-06-2010 09:34 PM
MichaelMacDonald
New Contributor
Hey folks, does anyone know of a methodology of selecting features from an ArcGISDynamicMapServiceLayer?

I know how to select features from a FeatureLayer, but is it possible with this type of layer as well?

Thanks!
0 Kudos
9 Replies
DominiqueBroux
Esri Frequent Contributor
From an ArcGISDynamicmapServiceLayer, you can use either 'Identify' which returns the features of the map service near a point (example : http://resources.esri.com/help/9.3/arcgisserver/apis/silverlight/samples/start.htm#Identify ) or a Query task which returns the features of a layer (example : http://resources.esri.com/help/9.3/arcgisserver/apis/silverlight/samples/start.htm#SpatialQuery).

If you are using the version 2.0 of the API, you can also consider using a featureLayer in SelectionOnly mode (Example : http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#FeatureLayerSelection).

Hope this help.

/Dominique
0 Kudos
MichaelMacDonald
New Contributor
From an ArcGISDynamicmapServiceLayer, you can use either 'Identify' which returns the features of the map service near a point (example : http://resources.esri.com/help/9.3/arcgisserver/apis/silverlight/samples/start.htm#Identify ) or a Query task which returns the features of a layer (example : http://resources.esri.com/help/9.3/arcgisserver/apis/silverlight/samples/start.htm#SpatialQuery).

If you are using the version 2.0 of the API, you can also consider using a featureLayer in SelectionOnly mode (Example : http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#FeatureLayerSelection).

Hope this help.

/Dominique


Dominque, it seems to be the FeatureLayer that's not showing up -- it's working just fine when I set it as a ArcGISDynamicmapServiceLayer in the XAML, but when I try it as a "FeatureLayer" with the selection mode shown in the sample I don't even see the layer rendering on load. 

Perhaps it's the way I have the service configured?  It's an MSD source obviously. 

Any idea what I could be doing wrong?
0 Kudos
dotMorten_esri
Esri Notable Contributor
Dominque, it seems to be the FeatureLayer that's not showing up -- it's working just fine when I set it as a ArcGISDynamicmapServiceLayer in the XAML, but when I try it as a "FeatureLayer" with the selection mode shown in the sample I don't even see the layer rendering on load.

Perhaps it's the way I have the service configured? It's an MSD source obviously.

Any idea what I could be doing wrong?


If you switch to using a featurelayer, remember to change the URL to use a layer within the service. For instance add /0 to the URL to select the feature layer to display.
0 Kudos
MichaelMacDonald
New Contributor
If you switch to using a featurelayer, remember to change the URL to use a layer within the service. For instance add /0 to the URL to select the feature layer to display.


Yeah I tried that too, still getting this error:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; MS-RTC LM 8; .NET4.0C; .NET4.0E)
Timestamp: Tue, 11 May 2010 19:27:50 UTC


Message: Unhandled Error in Silverlight 2 Application Invalid or unsupported json   at ESRI.ArcGIS.Client.Layer.OnInitializationFailed(EventArgs e)
   at ESRI.ArcGIS.Client.Layer.Initialize()
   at ESRI.ArcGIS.Client.FeatureLayer.info_Error(Object sender, TaskFailedEventArgs e)
   at ESRI.ArcGIS.Client.FeatureLayerInfo.OnError(Exception err)
   at ESRI.ArcGIS.Client.FeatureLayerInfo.FromJson(String json)
   at ESRI.ArcGIS.Client.FeatureLayerInfo.Execute_Completed(Object sender, DownloadStringCompletedEventArgs e)
   at System.Net.WebClient.OnDownloadStringCompleted(DownloadStringCompletedEventArgs e)
   at System.Net.WebClient.DownloadStringOperationCompleted(Object arg)
0 Kudos
DominiqueBroux
Esri Frequent Contributor
You are getting the same error than if your feature layer URL was incorrect.

Verify what you get if you execute a query on your feature layer URL. With the sample, you get this : http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/0?... (pjson =  format pretty json to be more readable).


/Dominique
0 Kudos
KevinSchumm
New Contributor
I have a question related to this topic. I have the above example working with a dynamic layer and a featurelayer in selectiononly mode. However, selection only seems to happen when I have the Editor selectionMode set to "Rectangle".

I'd like this same behavior to happen when I have the mode set to "Point" so the user can just click a feature instead of dragging a rectangle around it.

The point selection works if I set the FeatureLayer to OnDemand, but then the symbology for the feature shows at all zoom levels instead of just showing on the dynamic layer.

Does anyone have any suggestions to create this behavior?
0 Kudos
dotMorten_esri
Esri Notable Contributor
The problem with point mode against a point layer is the accuracy. When you are using the SelectionOnly mode, the selection is done against the server, and this is simply sending the coordinate you clicked to the server, and looking for any points that intersects that point. The thing is with point/point intersection that you have to hit EXACTLY at where that point is down to the last digit precision (note the intersection is done on the geometry, not the symbol which is a lot larger than an infinitely small point). In other words: Selection does work with point, IF you can click at the right point. However this is a good as impossible to do.
Bottomline: Do not use point as selection mode against a point layer.
0 Kudos
KevinSchumm
New Contributor
That's what I figured was going on, but I was hoping I was doing something wrong. Thanks for you help on this matter.

The problem is that we're replacing a system that DOES work this way, so we'll need to have some design discussions on our end.

Thanks again.
0 Kudos
DavidJacobs
New Contributor II
Is there a way to buffer the point query?  Or create a custom selection mode?
0 Kudos