tmap icon indicating copy to clipboard operation
tmap copied to clipboard

interactive synchronic maps in tmap not working in flexdasboard

Open PauGallesClara opened this issue 2 years ago • 2 comments

Hi I've created a map to compare 3 variables in an interactive mode using tmap. When I visualize the output using Rmarkdown in html I'm able to see the synchronicity. As it is shown in the attached picture screenshot1 Here you have the code for this combination map `map_SIR <- tm_shape (barris_SIR) + tm_polygons (c("SIR", "Y", "E"), style=c("cont", "cont"), palette=list("-RdBu", "Blues", "Greens"), auto.palette.mapping=FALSE, title=c("SIR", "Observats", "Esperats"))

tmap_leaflet(map_SIR) `

But when I use the output flexdasboard in rmarkdown it doesn't print anything.

On the contrary flexdasboard is able to print "single maps" representing one variable for each map. But then I loose the synchronicity as it is shown in pict 2 screenshot2

Can you help me in this issue?

PauGallesClara avatar May 02 '22 08:05 PauGallesClara

I never used flexdasboard, so probably cannot help.

Please test leafsync, the package that tmap uses under the hood.

Something like this should work in your case:

library(mapview)
library(leafsync)
m1 = mapview(barris_SIR , col = "SIR")
m2 = mapview(barris_SIR , col = "Y")
m3 = mapview(barris_SIR , col = "E")

sync(m1, m2, m3)

But I cannot reproduce it myself.

In case this also doesn't work please contact @tim-salabim

mtennekes avatar May 10 '22 08:05 mtennekes

Hi!! Thanks for your response I've tried your code and it works in the R file, but not in the dashboard as it happened with the tmaps. (Just one little correction with your example code: the parameter "col" is not correct, the good one is "zcol"

Anyway thank you for your help @mtennekes. I will contact @tim-salabim and ask for help

PauGallesClara avatar May 10 '22 11:05 PauGallesClara