Skip to content

Commit

Permalink
Fix issue with reloadLayer overwriting url
Browse files Browse the repository at this point in the history
  • Loading branch information
tariqksoliman committed Jun 18, 2024
1 parent cae65a6 commit 2be2bf5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/essence/Ancillary/TimeControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,16 @@ var TimeControl = {
// refresh map
if (evenIfControlled === true || layer.controlled !== true)
if (L_.layers.on[layer.name] || evenIfOff) {
return await Map_.refreshLayer(layer)
return await Map_.refreshLayer(layer, () => {
// put start/endtime keywords back
if (layer.time && layer.time.enabled === true)
layer.url = originalUrl
})
}
}
}
// put start/endtime keywords back
if (layer.time && layer.time.enabled === true) layer.url = originalUrl

return true
},
performTimeUrlReplacements: async function (url, layer) {
Expand Down
4 changes: 3 additions & 1 deletion src/essence/Basics/Map_/Map_.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ let Map_ = {
)
}
},
refreshLayer: async function (layerObj) {
refreshLayer: async function (layerObj, cb) {
// We need to find and remove all points on the map that belong to the layer
// Not sure if there is a cleaner way of doing this
for (var i = L_._layersOrdered.length - 1; i >= 0; i--) {
Expand All @@ -419,8 +419,10 @@ let Map_ = {
console.error(
`ERROR - refreshLayer: Cannot make layer ${layerObj.display_name}/${layerObj.name} as it's already being made!`
)
if (typeof cb === 'function') cb()
return false
}
if (typeof cb === 'function') cb()
return true
}
}
Expand Down

0 comments on commit 2be2bf5

Please sign in to comment.