I am attempting to incorporate custom weather tiles onto a leaflet
map within a Shiny application by utilizing the leaflet-openweathermap
JavaScript library found here. As someone who is not well-versed in JavaScript, I am encountering difficulties with rendering the weather layers on the map.
My approach involved downloading leaflet-openweathermap.js
and storing it within the www/js
directory of my application. Next, I registered the plugin:
openWeatherPlugin <- htmlDependency(
"Leaflet.OpenWeather",
"1.6.0",
src = normalizePath(path = getwd()),
script = "www/js/leaflet.openweathermap.js"
)
In order to display a weather layer on leaflet, I implemented the following:
leaflet() %>%
addTiles() %>%
registerPlugin(openWeatherPlugin) %>%
onRender("
function(el, x){
L.OWM.clouds({showLegend: true, opacity: 0.5, appId: 'MY_APP_ID'})
}
")
The value for MY_APP_ID
is a valid identifier obtained from openweathermap.org
Despite these efforts, the code does not produce the desired cloud weather layer. Due to my limited knowledge of JavaScript, I am unsure of what may be causing this issue. Any assistance or guidance would be greatly appreciated.