0

I am using mapview in R to plot maps. I have more tha 100 polygons and I want to show them on the map with the names on it every time. But I couldn’t find a solution to this issue. Any idea?

mp<-st_read('https://raw.githubusercontent.com/mgaitan/departamentos_argentina/master/departamentos-buenos_aires.json',stringsAsFactors= FALSE)
mapview(mp, zcol='cabecera')

map photo

1 Answers1

3

Assuming that you mean you want static labels that are always on the map, rather than just when you hover on them, you could use addStaticLabels() from {leafem}:

library(leafem)
mp<-st_read('https://raw.githubusercontent.com/mgaitan/departamentos_argentina/master/departamentos-buenos_aires.json',stringsAsFactors= FALSE)
mapview(mp, zcol='cabecera') %>%
  addStaticLabels(mp,
                  mp$cabecera,
                  noHide = TRUE,
                  textsize = "6px",
                  style = list("background-color" = "white", "font-weight" = "bold"))

which gives:

Mapview with labels

nrennie
  • 1,877
  • 1
  • 4
  • 14