rmapsmapview

How to use addStaticLabels with mapview


I am trying to use addStaticLabels with mapview but the outline of the map disapears. Could someone help me figure out what's going on?

If I run:

library(mapview)
library(leafem)
 mapview(franconia)

It works as expected.

But running it like so:

mapview(franconia) %>% addStaticLabels(., label = franconia$NAME_ASCI)

It prints the labels but the outline of franconia goes away. Am I missing something?


Solution

  • You can pipe the map directly into the label function:

    library(mapview)
    library(leafem)
    
    
    mapview(franconia) |> 
      addStaticLabels(label = franconia$NAME_ASCI)
    

    Created on 2023-12-22 with reprex v2.0.2