tmap icon indicating copy to clipboard operation
tmap copied to clipboard

Adjust symbol size when zooming in interactive view mode

Open xiaofanliang opened this issue 4 years ago • 1 comments

In the current view mode, the symbol size is constant when zooming in and out of the map. I would like to have the symbol size adapt automatically or manually based on the zoom level (e.g., bigger on higher-level zoom and smaller on lower level zoom). This function is automatically achieved in leaflet when you addCircleMarkers(). https://rstudio.github.io/leaflet/markers.html

I tried setting the symbol.size.fixed argument in tm_view to FALSE and it does not work. There seems to be a possibility to wrap leaflet functions in tmap through the leaflet.options, but I don't know how to do it correctly.

Currently, my workaround is just to use leaflet like the link above (or see below example). I would love to be able to do that through tmap so that I don't have to introduce another package in my tutorial.

leaflet(df) %>% addTiles() %>%
  addCircleMarkers(
    radius = ~degree,
    color = ~pal(type),
    stroke = FALSE, fillOpacity = 0.5
  )

Let me know if this is possible? Many thanks!

xiaofanliang avatar Nov 04 '21 03:11 xiaofanliang

Small reprex of the current behavior:

library(tmap)
library(spData)
ttm()

tm_shape(nz) +
  tm_markers()

Nowosad avatar Jan 16 '25 09:01 Nowosad