socib / Leaflet.TimeDimension

Add time dimension capabilities on a Leaflet map.
MIT License
433 stars 138 forks source link

Other WMS requests being called #199

Open bambryan opened 3 years ago

bambryan commented 3 years ago

I have been looking at my making my page more efficient and found that when my map loads at zoom level 9 with 1 layer with time dimension of 30 min period and 2 min time steps, it calls for the layer with no time dimension in the web request and then it calls for the last frame which is the time dimension that I am forcing the slider to move to at time of load. It also then requests the first and second time steps. Not sure if it's something I have done with my coding or if others are seeing this.

Thanks Bryan

r1m commented 3 years ago

it calls for the layer with no time dimension in the web

Do you add both the seed layer and the timedimension one to the map ? You must not.

It also then requests the first and second time steps.

It prefetches next layers to reduce loading times when the playback starts. You can customize buffer and minBufferReady options on the player. But Is it configure with loop:true ?

bambryan commented 3 years ago

I am only adding the TD layer as shown in the screenshot attached. I am fine with the loading of other frames from the beginning of the timeline.

Screen Shot 2020-09-04 at 11 00 20 AM

r1m commented 3 years ago

I'm sure not about your expectation. But you can try to hide the layer and show it only after changing the time.

bambryan commented 3 years ago

The expectation is that there is extra calls happening when the layer is loaded initially. The layer is added to the map using the code above in the screenshot. The layer is an hour of time at 2 minute steps. The script pulls the available times from the Postgis DB and gives them to the plugin then tells the plugin to goto the last available time. This is fine but it's calling for the layer without a time dimension, oldest 2 steps and the most current. So I'm confused on why it is calling for the layer without a time dimension all together when it's being added to the map by the plugin.

Sample #2 also does it. If you inspect or watch the network request of images you will see multiple times being requested at the start and also tiles that have no time dimension specified.

r1m commented 3 years ago

Because it doesn't wait for the getCapabilities response. And default time value is empty. Maybe we can check availableTime in _update function and do not add/remove the layer when the array is empty.

This may be a breaking change so it might be better to add an option to change the behavior. Any PR is welcome 😄

bambryan commented 3 years ago

I'm not using getCababilities to get my times. I"m using a function to ping the PostGIS database for available times. So if I set the default time value to current time then it shouldn't do what it's doing?

r1m commented 3 years ago

I guess. You can try to update the timedimension object before adding the layer. Be sure to wait for async call results.