Select to view content in your preferred language

Specify Map Service layers to draw

1263
11
12-09-2010 06:09 AM
JayKappy
Frequent Contributor
WMS I did this

XAML:
<esri:WmsLayer ID="AGSWMSLayer" 
Url="http://serverapps.esri.com/ArcGIS/services/California/MapServer/WMSServer"
Initialized="WmsLayer_Initialized"/>

VB:
Private Sub WmsLayer_Initialized(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Dim myWmsLayer As ESRI.ArcGIS.Client.Toolkit.DataSources.WmsLayer
    myWmsLayer = TryCast(MyMap.Layers("AGSWMSLayer"), ESRI.ArcGIS.Client.Toolkit.DataSources.WmsLayer)
    ' You can control the visibility of which WMS layers are displayed by adding the
    ' sub-LayerID's to the String Array. 
    Dim myVisibleWmsLayers() As String = {"0", "1", "2", "3", "4", "5", "6", "7", "8"}
    myWmsLayer.Layers = myVisibleWmsLayers
End Sub


But now I have a ArcGISDynamicMapServiceLayer.....

I cant figure out how to specify which layer draws....this below line has to change...how do I DIM the DynamicMapSerive Layer....As its not a GeoRSSLayer, HeatMapLayer, OpenStreetMapLayer, or WMS Layer
    Dim myWmsLayer As ESRI.ArcGIS.Client.Toolkit.DataSources.WmsLayer

Any thoughts on how to specify individual layers in the Map Service to draw?

Thanks
0 Kudos
11 Replies
JayKappy
Frequent Contributor
FIRST OFF WHERE DID YOU FIND THAT EXAMPLE...IT WAS NOT IN ANY EXAMPLE YOU GAVE ME....I qwas going off of what you gave me:
http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.ArcGISDyna...
THATS ALL I WAS LOOKING FOR...
Now that makes sense...I was referencing the online example from the API...the one you pointed me to...It did not look anything like what you just sent...and much more complex...all of that to simply define what layers you want to see....Was it more involved to push to a textblock????
Your example should be on the API site!!!

I was trying to break that example down into this:  The first few lines but it was not working...
        '' Get the first layer in the LayerInfo collection. 
        Dim myArcGISDynamicMapServiceLayer As ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer = MyMap.Layers.Item(0)

        '' Uncomment the next two lines of code to set only the 2nd and 3rd sub-layers to be visible.
        Dim myVisibleLayers2() As Integer = {1}
        myArcGISDynamicMapServiceLayer.VisibleLayers = myVisibleLayers2


BUT I REALLY do apprecaite the help...its greatly appreciated....

So in your example would you do this?

        Dim l As ArcGISDynamicMapServiceLayer = TryCast(Me.MyMap.Layers(1), ArcGISDynamicMapServiceLayer)
        l.VisibleLayers = New Integer() {0}

OR

        Dim l As ArcGISDynamicMapServiceLayer = TryCast(Me.MyMap.Layers("MyLayer"), ArcGISDynamicMapServiceLayer)
        l.VisibleLayers = New Integer() {0}



THANK YOU
0 Kudos
JenniferNery
Esri Regular Contributor
The API Reference I linked you to is one that demonstrates how you can retrieve the current value of VisibleLayers property and display on a TextBlock.

The SDK Sample I linked you to is one that gets and sets the VisibleLayers property dynamically based on checked sub layers.

They are both valid examples.

The code snippet in Post #10 is no different from our SDK sample. It is just simpler because I hardcoded the sub layer ID I want visible.

To answer your other question, it is preferrable to get the layer by ID as I have already mentioned in my previous post. The reason is that you may be adding/removing layers or change the order of your layers later on. While the layer index may change in these scenarios, the ID will not.
0 Kudos