leaflet.extras2
leaflet.extras2 copied to clipboard
addWMS with interactive options
Hi Everyone I tried to use the addWMS in shiny to plot a map from web services. I want the map from addWMS to change dynamically when I provide a different DateTime to it. The addWMS could plot the map with provided initial DateTime. However, no map was shown when I change the DateTime with a sidebar. I am sure the input DateTime is correct. and the error from the console are the following. How I use addWMS in R
output$mymap <- renderLeaflet({
leaflet() %>%
setView(lng = -76, lat = 47, zoom = 4) %>%
addProviderTiles(providers$OpenStreetMap.Mapnik) %>%
addWMS(baseUrl = baseUrl,
layers = "GEPS_Pgrid_3hr",
options = WMSTileOptions(
version = "1.3",
showContours="false",
#time= "2022-11-10T21:00:00Z",
time= datetime_list()$few_time,
styles = "",
format = "image/png",
transparent = "true",
uppercase = "false"
)
)
})
The error from concole
Uncaught TypeError: t.onRemove is not a function
at e.removeLayer (leaflet.js:5:65194)
at e.removeFrom (leaflet.js:5:64166)
at e.remove (leaflet.js:5:64092)
at e.remove (leaflet.js:5:36838)
at Object.renderValue (leaflet.js:633:15)
at Object.renderValue (htmlwidgets.js:889:25)
at shinyBinding.renderValue (htmlwidgets.js:543:20)
at e.value (outputBinding.ts:48:12)
at delegator.<computed> [as onValueChange] (htmlwidgets.js:112:23)
at e.value (outputAdapter.ts:39:20)
leaflet.js:5
Uncaught Error: Map container is being reused by another instance
at e.remove (leaflet.js:5:36414)
at Object.renderValue (leaflet.js:633:15)
at Object.renderValue (htmlwidgets.js:889:25)
at shinyBinding.renderValue (htmlwidgets.js:543:20)
at e.value (outputBinding.ts:48:12)
at delegator.<computed> [as onValueChange] (htmlwidgets.js:112:23)
at e.value (outputAdapter.ts:39:20)
at e.value (shinyapp.ts:565:17)
at e.<anonymous> (shinyapp.ts:743:20)
at e.value (shinyapp.ts:724:29)
leaflet.js:5
Uncaught TypeError: Cannot read properties of undefined (reading 'style')
at wt (leaflet.js:5:9820)
at e.<anonymous> (leaflet.js:5:47376)
at e.fire (leaflet.js:5:16621)
at e.invalidateSize (leaflet.js:5:34738)
at Object.resize (leaflet.js:798:15)
at Object.resize (htmlwidgets.js:892:25)
at shinyBinding.resize (htmlwidgets.js:553:24)
at outputAdapter.ts:26:17
at e.onResize (index.ts:138:5)
at HTMLDivElement.<anonymous> (init.ts:266:15)
Hey, thanks for that issue. Could you maybe post a minimal reproducible example? It would make debugging much easier for me.