1

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?

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

Reference: Print label on circle markers in leaflet in Rshiny

1 Answer 1

2

fillOpacity = before labelOptions:

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, 
    fillOpacity = 0.9, 
    labelOptions = labelOptions(noHide = TRUE, fill = FALSE, offset = c(5,2), textsize = "18px", textOnly = TRUE))

Not the answer you're looking for? Browse other questions tagged or ask your own question.