Select to view content in your preferred language

Refresh WMS Layer

676
6
02-29-2012 11:23 AM
JayKappy
Frequent Contributor
I am trying to refresh a WMS weather Layer....
its not refreshing....read soemthing about disableCache or something...

What am I missing?

Thanks

<esri:WmsLayer ID="Nexrad" Url="http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi?" Version="1.3.0" 
      SkipGetCapabilities="True" Initialized="Nexrad_Initialized" Opacity=".5"  Visible="True" />


    Private Sub UserControl_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)

        ' Timer to refresh Weather
        Dim localTimer As New DispatcherTimer()
        AddHandler localTimer.Tick, AddressOf localTimer_Tick
        localTimer.Interval = New TimeSpan(0, 0, 30)

    End Sub

    Private Sub localTimer_Tick(ByVal sender As Object, ByVal e As EventArgs)
        Dim nexradWmsLayer As ESRI.ArcGIS.Client.Toolkit.DataSources.WmsLayer = Nothing
        nexradWmsLayer = TryCast(MyMap.Layers("Nexrad"), ESRI.ArcGIS.Client.Toolkit.DataSources.WmsLayer)
        nexradWmsLayer.Refresh()
    End Sub

    Private Sub Nexrad_Initialized(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim nexradWmsLayer As ESRI.ArcGIS.Client.Toolkit.DataSources.WmsLayer = Nothing
        nexradWmsLayer = TryCast(MyMap.Layers("Nexrad"), ESRI.ArcGIS.Client.Toolkit.DataSources.WmsLayer)

        Dim VisibleWmsLayers As String() = {"nexrad-n0r-900913-m05m"}
        nexradWmsLayer.Layers = VisibleWmsLayers
    End Sub
0 Kudos
6 Replies
JayKappy
Frequent Contributor
Something like this

nexradWmsLayer.DisableClientCaching = True

I try the below but get an error that the DisableClientCaching is not a member of Toolkit.DataSources.WMSLayer

    Private Sub Nexrad_Initialized(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim nexradWmsLayer As ESRI.ArcGIS.Client.Toolkit.DataSources.WmsLayer = Nothing
        nexradWmsLayer = TryCast(MyMap.Layers("Nexrad"), ESRI.ArcGIS.Client.Toolkit.DataSources.WmsLayer)

        nexradWmsLayer.DisableClientCaching = True        

        Dim VisibleWmsLayers As String() = {"nexrad-n0r-900913-m05m"}
        nexradWmsLayer.Layers = VisibleWmsLayers
    End Sub
0 Kudos
JayKappy
Frequent Contributor
I placed a msgbox on the timer and It never fires...

    Private Sub localTimer_Tick(ByVal sender As Object, ByVal e As EventArgs)

        MessageBox.Show("timer")

        Dim nexradWmsLayer As ESRI.ArcGIS.Client.Toolkit.DataSources.WmsLayer = Nothing
        nexradWmsLayer = TryCast(MyMap.Layers("Nexrad"), ESRI.ArcGIS.Client.Toolkit.DataSources.WmsLayer)
        ' Refresh the layer
        nexradWmsLayer.Refresh()
    End Sub
  



I also placed a button on the form adn this code./....the messagebox fires but does not seem to refresh....

<Button x:Name="Refresh"  Width="20" Height="20" Content="x" FontSize="8" 
          Click="RefreshWeather" Foreground="Black" Effect="{StaticResource miniDropShadow}" Margin="0,0,20,0"/>
  

                          
    Private Sub RefreshWeather(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
        MessageBox.Show("Refresh Button")

        Dim nexradWmsLayer As ESRI.ArcGIS.Client.Toolkit.DataSources.WmsLayer = Nothing
        nexradWmsLayer = TryCast(MyMap.Layers("Nexrad"), ESRI.ArcGIS.Client.Toolkit.DataSources.WmsLayer)
        ' Refresh the layer
        nexradWmsLayer.Refresh()
    End Sub
  
0 Kudos
JayKappy
Frequent Contributor
I changed the code to this and I am now getting the timer to work as the messagebox fires....BUT the WMS layer IS NOT refreshing...

If I uncomment these two lines the layer Aerials is set to false and disappears..
        'Dim arcgisLayer As ArcGISTiledMapServiceLayer = TryCast(MyMap.Layers("Aerials"), ArcGISTiledMapServiceLayer)
        'arcgisLayer.Visible = False

Why wont the WMS layer Refresh?

    Private Sub UserControl_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
        timerNew = New DispatcherTimer()
        timerNew.Interval = TimeSpan.FromMilliseconds(3000)
        AddHandler timerNew.Tick, AddressOf timer_OnTickNew
    End Sub


    Private Sub timer_OnTickNew(ByVal sender As Object, ByVal e As EventArgs)
        MessageBox.Show("New timers")

        Dim nexradWmsLayer As ESRI.ArcGIS.Client.Toolkit.DataSources.WmsLayer = Nothing
        nexradWmsLayer = TryCast(MyMap.Layers("Nexrad"), ESRI.ArcGIS.Client.Toolkit.DataSources.WmsLayer)
        
        ' Refresh the layer
        nexradWmsLayer.Refresh()

        'Dim arcgisLayer As ArcGISTiledMapServiceLayer = TryCast(MyMap.Layers("Aerials"), ArcGISTiledMapServiceLayer)
        'arcgisLayer.Visible = False

    End Sub
0 Kudos
JayKappy
Frequent Contributor
Can I even refresh a WMS layer?  Puzzled here...is it getting cached?
I dont get an error now but the WMS weather service does not refresh...
I have to close the app wait a few seconds and then reopen and it refreshes..
hmmmmmmm
THanks
0 Kudos
JenniferNery
Esri Regular Contributor
What are you trying to accomplish with Refresh() anyway? Every time the map extent changes, WMS layer will try to re-draw using GetUrl().
0 Kudos
samulineuvonen
Deactivated User
Hello,

Just replying to Jennifers question: Wouldn't refresh be the ideal way to update e.g. the positions of moving vehicles provided in a WMS without having the whole map to be redrawn? Or is there another way to have only one layer update? Or does refresh on one layer always refresh the whole map?

Regards,
Samuli
0 Kudos