'Dynamicaly change leafletjs tilelayer
How can i load new images for TileLayer after changing date in request?
or
How I can update already created TileLayers with new date option?
I have TileLayers from OpenWeatherMap requests is generated with this code
openweathermap_overlay = new L.TileLayer(
"http://maps.openweathermap.org/maps/2.0/weather/{op}/{z}/{x}/{y}?appid={API_key}",
{
API_key: key,
date: date,
op: op_key
})
In my mind it must be something like here: https://openweathermap.org/weathermap?basemap=map&cities=false&layer=radar&lat=56.9510&lon=24.1064&zoom=5
While you drag date you can see that tiles changing Of course i have tried something like this:
date: getDate(),
And this doesn't work.
Great Thanks for every advice.
Solution 1:[1]
Ok It was so easy.
var url = "http://maps.openweathermap.org/maps/2.0/weather/{op}/{z}/{x}/{y}?appid={API_key}&opacity={opacity}&date="
openweathermap_overlay = new L.TileLayer(
url+date,
{
API_key: key,
op: op_key
})
openweathermap_overlay.setUrl(url+new_date)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | StormInside |
