Home > Software engineering >  Leaflet default markers not showing in R
Leaflet default markers not showing in R

Time:03-24

I have been using Leaflet for R for years with no problems. This morning, the default markers are no longer appearing on my maps, even though the popups appear on the hovers.

I can reproduce the behavior with the simplest built-in utilities:

library(leaflet)
data(quakes)
leaflet(data = quakes[1:20,]) %>% addTiles() %>%
  addMarkers(~long, ~lat, popup = ~as.character(mag), label = ~as.character(mag))

enter image description here

I have deleted the leaflet folder from R and reinstalled the package (v2.1.0), but still get the same results.

Does anyone have any idea what might be causing this and how I can troubleshoot/fix it? I'm considering deleting and reinstalling R, but would love to know if there's a better option.

Thanks!

CodePudding user response:

As @Wimpel said in the comments, you could use the addCircleMarkers() command. You can use the following code:

library(leaflet)
data(quakes)
leaflet(data = quakes[1:20,]) %>% addTiles() %>%
  addCircleMarkers(~long, ~lat, popup = ~as.character(mag), label = ~as.character(mag))

Output:

enter image description here

CodePudding user response:

Package maintainer knows about the problem. It will be fixed in the next version posted to CRAN (hopefully in a few days).

In the meantime, you can install the fixed version from github:

remotes::install_github("rstudio/leaflet")
  • Related