Select to view content in your preferred language

Refresh WMS Layer

4641
12
06-15-2010 12:30 PM
BrianGustafson
Occasional Contributor
I have a timer set up so that at each tick the WMS layer(weather radar) will update.  When I use the refresh method the WMS is not updated until I pan the map.  Is there some other way to update WMS layers without needing to pan the map?
0 Kudos
12 Replies
DanielWalton
Frequent Contributor
Put it in:

public override void GetUrl(Envelope extent, int width, int height, DynamicMapServiceLayer.OnUrlComplete onComplete)
{
...
}


Esri provides the source to these classes because they know folks will want to modify them. So go ahead and modify 🙂
0 Kudos
samulineuvonen
Deactivated User
OK, I was able to get it working. Thanks to you, Dan!

Also, I think I was able to implement some sort of control over the queueing requests, not by Javascrit but by using the LostFocus- and GotFocus-events of the MainPage (RootVisual) and another timer checking if the focus was lost and not returned for more than 5 seconds (in which case the actual timer was stopped). We'll see how this works in production...

Thanks again,
Samuli
0 Kudos
samulineuvonen
Deactivated User
One more update to this, although a bit of topic: I was able to use this same approach to implement a sort-of "TimeAware" WMS layer. I added both a property named "Autorefresh" and the code below in the GetURL-function in the WMS.cs and then created a custom TimeSlider-control, which updates the VisibleTimeExtent-property of the referenced WMS layers. Seems to work nicely, so just in case someone else is trying to solve this...

S

if (this.Autorefresh==true)
{
    //autorefresh
    mapURL.AppendFormat("&t={0:hhmmss}", DateTime.Now);
}
else if (this.VisibleTimeExtent != null)
{
    if (this.VisibleTimeExtent.Start == this.VisibleTimeExtent.End)
    {
        mapURL.AppendFormat("&TIME={0:yyyy-MM-ddTHH:mm:ss.sssZ}", this.VisibleTimeExtent.Start);
    }
    else
    {
        mapURL.AppendFormat("&TIME={0:yyyy-MM-ddTHH:mm:ss.sssZ}/{1:yyyy-MM-ddTHH:mm:ss.sssZ}", this.VisibleTimeExtent.Start, this.VisibleTimeExtent.End);
    }
}
0 Kudos