Select to view content in your preferred language

How to tell if layer is visible, but not in the current extent?

956
4
11-04-2010 10:46 AM
BrentStevener
Deactivated User
I am trying to duplicate the way the layer tree worked in the Web ADF Mapping Application, but in a Silverlight control. In the Web ADF layer tree, for times when a layer is visible, but not displayed in the current extent, the item was greyed out (but checked). When the layer became visible in the current extent, the item was enabled for toggling on/off.

How can I check to see if this layer is visible, but not currently displayed in the map extent, in order to do what I want with my list item? I can query the layer and figure out that it is visible, but I am not sure how to then check if the layer is actually displayed in the map service layer. The layer only shows when you zoom in to a certain extent. Right now the layer, when checked in the list, is being returned in dynamicServiceLayer.VisibleLayers, even though the layer is not shown at that extent (which is correct, I am assuming). I just need to go one step further and see if this is actually showing up in the map service in the current extent.
0 Kudos
4 Replies
DominiqueBroux
Esri Frequent Contributor
In the Release Canditate available here : http://help.arcgis.com/en/webapi/silverlight/2.1/ , there is a new Legend control which hopefully will do what you are expecting.
0 Kudos
BrentStevener
Deactivated User
The Legend control in 2.1 looks like it allows for this, but then I lose the flexibility I have with building the treelist myself, since I can embed layers (like Feature Layers) wherever I want, in whatever order, and add/remove them as I see fit (as opposed to just binding them to a map service).

There is an IsInScaleRange property of the LayerItemViewModel class, which the Legend sample uses to enable/disable the list item depending if it is within the current view scale, but how can I check to see if a layer is in the scale range if I am not using the Legend control? That's the property I need, but I need to be able to access it without using the Legend control.
0 Kudos
DominiqueBroux
Esri Frequent Contributor

I have with building the treelist myself,since I can embed layers (like Feature Layers) wherever I want, in whatever order, and add/remove them as I see fit

If you set the LayerIDs property of the legend control, the layer legend will be displayed in the order given by this list of layers.
You can also add/remove/change legend items by hooking up to LegendControl.refreshed event.


but how can I check to see if a layer is in the scale range if I am not using the Legend control? That's the property I need, but I need to be able to access it without using the Legend control.

The code of the 2.1 toolkit is now available here : http://esrisilverlight.codeplex.com/ so you can look at the implementation of IsInScaleRange in the legend control.
0 Kudos
BrentStevener
Deactivated User
Thanks for the info. I have been playing with the Legend control more and I have almost got it to do what I want. The issue comes when you have two different map services, and want them to show as one tree (instead of two different services) in the legend. Using the "flat" LayerItemsMode property of the Legend collapses these into one tree, but you also lose the group layers in each respective service, when we would rather keep these group layers.

Say you have one regular dynamic map service, and one feature layer. In the legend, these show as two separate services (with layers and swatches underneath each respective service), when we would prefer that the feature layer be the first in the tree list (however, it would be even better if we could put it anywhere in the list) and not grouped in its own service. This feature layer is related to the dynamic map service, and we would prefer that the user not see that it is in its own separate tree away from all the other layers in the dynamic map service.

Don't get me wrong, this Legend control is great, and it works for 95% of everything else we do. I am just asking these questions because this is a special case.
0 Kudos