Home > Net >  R: Making More "Noticeable" Labels in R Leaflet map
R: Making More "Noticeable" Labels in R Leaflet map

Time:02-21

I made the following map in R (from a data frame with 5 points ordered from "1" to "5"):

library(dplyr)
library(leaflet)

map_data <- data.frame("Lat" = c(43.6426, 43.6424, 43.6544, 43.6452, 43.6629), "Long" = c(-79.3871, -79.3860, -79.3807, -79.3806,-79.3957 ), type = c(1,2,3,4,5))
map_data$type = as.factor(map_data$type)


leaflet(map_data) %>% addTiles() %>% addCircleMarkers(stroke = FALSE, label = ~type,
    labelOptions = labelOptions(noHide = TRUE, offset=c(0,-12), fill = TRUE, opacity = 10, weight = 10, textOnly = TRUE))

But the problem is, you can barely see the "labels" for each city:

enter image description here

I would like to make the "labels" a lot more noticeable, something like this:

enter image description here

I tried to play around with the "weight" and "opacity" arguments, but this does not seem to be working.

Can someone please show me how to do this?

Thanks!

Note: I do not want to do this in R SHINY, just using LEAFLET in R.

Reference:

  • Related