-
Notifications
You must be signed in to change notification settings - Fork 125
Description
I am trying to create some interactive tmaps. I wanted to take advantage of the radio buttons in TMAP v4, to display different data inside the same .html-file.
My first question is around using group.control = "radio". While this works, it puts the layer data in the same level with the basemaps. In reality users want to have a basemap PLUS one custom layer. Take this example:
library(tmap)
data(World)
# Create interactive map with group control set to radio
tmap_mode("view")
map <- tm_shape(World) +
tm_polygons("pop_est", group = "Population", group.control = "radio") +
tm_polygons("gdp_cap_est", group = "GDP", group.control = "radio") +
tm_basemap(c("Esri.WorldGrayCanvas", "CartoDB.Voyager"))
map
How can I achieve it? I have also tried tm_group(...,control = "radio"), but that doesn't seem to work.
Moreover, if one of the layer names has special characters (in my case Umlaut ä) as the group name, the layer doesn't work as expected. Take this example:
library(tmap)
data(World)
# Create interactive map with group control set to radio
tmap_mode("view")
map <- tm_shape(World) +
tm_polygons("pop_est", group = "Populätion", group.control = "radio",
fill.legend = tm_legend(title = "Populätion Estimate")) +
tm_polygons("gdp_cap_est", group = "GDP per Capita", group.control = "radio",
fill.legend = tm_legend(title = "GDP per Capita")) +
tm_basemap(c("Esri.WorldGrayCanvas", "CartoDB.Voyager"))
map
The legend for layers with Umlaut is always shown. This indicates a character mismatch between the name of the legend (including Umlaut) and the Layer Control window. This unexpected behavious is also passed on, when converting tmap to leaflet. I tried to use baseGroups and overlayGroups to resolve the first issue, however, the legends of layers with Umlaut are always visible, no matter what.
See attached photos for both issues
Originally posted on stackoverflow to ask for advice, pasted in here as it is potentially a bug.
