Select to view content in your preferred language

Slide between layers

4644
11
03-04-2011 12:26 PM
JayKappy
Frequent Contributor
Looking for an example of a slide bar that moves from one layer to another...increases and decreases the transparency from one to the other....

Say from Streets to Aerials.....

THanks
0 Kudos
11 Replies
DominiqueBroux
Esri Frequent Contributor

I can get this to work with my map service...but tryign to use ESRIs and it wont work.....

I can't figure out why it could be not working with ESRI services.

I tested this code and it works:

<esri:Map x:Name="MyMap" >
<esri:ArcGISTiledMapServiceLayer ID="StreetMap" Visible="True" 
           Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" Opacity="1.0"/>
<esri:ArcGISTiledMapServiceLayer ID="Topo" Visible="True" 
           Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer" Opacity="0.0"/>
<esri:ArcGISTiledMapServiceLayer ID="Aerials" Visible="True" Opacity="0.0"
Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer" />
</esri:Map>
<Slider Height="23" HorizontalAlignment="Left" Margin="10,150,0,0" VerticalAlignment="Top" Width="100" Maximum="2" Minimum="0" ValueChanged="Slider_ValueChanged"/>
.........
 
private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
    var value = e.NewValue;
 
    if (value <= 1)
    {
        MyMap.Layers["StreetMap"].Opacity = 1.0 - value;
        MyMap.Layers["Topo"].Opacity = value;
        MyMap.Layers["Aerials"].Opacity = 0.0;
    }
    else
    {
        MyMap.Layers["StreetMap"].Opacity = 0.0;
        MyMap.Layers["Topo"].Opacity = 2 - value;
        MyMap.Layers["Aerials"].Opacity = value - 1;
    }
}
0 Kudos
JayKappy
Frequent Contributor
Thanks that worked out great.....as I said I think my problem was the Private sub and its parameters...
In my example I was unable to do this "Dim Value = e.NewValue"

The only way I could get mine to work was like this....but that was only with my specific layers not the ESRI ArcGISTiledMapServiceLayer map services...

        
        Dim value As Double = MySlider.Value

        Dim l_Parcels As ArcGISDynamicMapServiceLayer = TryCast(Me.MyMap.Layers("MG_Parcels"), ArcGISDynamicMapServiceLayer)
        Dim l_Parcels2 As ArcGISDynamicMapServiceLayer = TryCast(Me.MyMap.Layers("MG_Streets"), ArcGISDynamicMapServiceLayer)

        l_Parcels.Opacity = value 
        l_Parcels2.Opacity = 1 - value 


Was trying this...
    Private Sub MultiLayerOpacityTurnOn1_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)


Your example...

I am confused on where and when to use RoutedPropertyChangedEventArgs or RoutedEventArgs...Maybe you can shed some light on that?

    Private Sub Slider_ValueChanged(ByVal sender As Object, ByVal e As RoutedPropertyChangedEventArgs(Of Double))



THANKS FOR YOUR HELP.....
0 Kudos