r-spatial / mapview

Interactive viewing of spatial data in R
https://r-spatial.github.io/mapview/
GNU General Public License v3.0
516 stars 91 forks source link

addStaticLabels offset is ignored #466

Closed FelipeCarrillo closed 9 months ago

FelipeCarrillo commented 9 months ago

The offset argument seems to be ignored. Am I using offset the correct way?

library(mapview);library(leafem)
mapview(franconia)  %>% addStaticLabels(label = franconia$NAME_ASCI, 
                                         style = list(noHide = TRUE,
                                                direction = 'bottom',
                                                textOnly = TRUE,
                                                offset =c(5,7),
                                                color='red'))
tim-salabim commented 9 months ago

As the documentation states, ... are passed on to leaflet::labelOptions. Hence,

library(mapview)
library(leafem)
library(leaflet)

mapview(franconia)  %>% 
  addStaticLabels(
    label = franconia$NAME_ASCI, 
    noHide = TRUE,
    direction = 'bottom',
    textOnly = FALSE,
    offset =c(5,7),
    style = list(color='red')
  )

does what we expect.