Fisseha Berhane
Fisseha Berhane

Reputation: 2653

Remove label background in leaflet maps with R

I want to use static labels in my leaflet markers but I do not want the white background that shows with the labels. Is it possible to show only the text without the white background.

library(leaflet)
temp=data.frame(lng=c(-90,-100),lat=c(30,35))

leaflet(temp) %>% addTiles() %>%
    addCircleMarkers(~lng,~lat)%>%
    addPopups(~lng, ~lat,'<b>Hello, world</b>!', 
              options = popupOptions(minWidth = 20, closeOnClick = FALSE, closeButton = FALSE))

enter image description here

Upvotes: 1

Views: 2131

Answers (2)

Fisseha Berhane
Fisseha Berhane

Reputation: 2653

Adding label in addMarkers solved my problem.

    library(leaflet)
   temp=data.frame(lng=c(-90,-100),lat=c(30,35))

  leaflet(temp) %>% addTiles() %>%
    addMarkers(data=temp, ~lng,~lat,
                label=~as.character(lat),
               labelOptions = labelOptions(noHide = T,
                               textOnly = T,textsize = "28px",offset = c(12, -5)))

enter image description here

Upvotes: 1

sconfluentus
sconfluentus

Reputation: 4993

Yes, but you will find that it works with various degrees of success right out of the Github box. But is it pretty straight forward. You will want to use this and then with the labels setOpacity. It will affect both markers and labels.

Here is the link to a pluggin you need:

Leaflet R Pluggin & directions

Upvotes: 0

Related Questions