Within the leaflet package for R, is there a way to click on a marker, and be directed to a URL?*
This seems to be possible in JS.
It's easy to add a standalone Popup with a URL:
library(leaflet)
content <- paste(sep = "<br/>",
"<b><a href='http://www.samurainoodle.com'>Samurai Noodle</a></b>"
)
leaflet() %>% addTiles() %>%
addPopups(-122.327298, 47.597131, content,
options = popupOptions(closeButton = FALSE)
)
It's also straightforward to add a Marker that, when clicked, provides a URL in the popup:
leaflet() %>% addTiles() %>%
addMarkers(-122.327298, 47.597131, popup = content,
options = popupOptions(closeButton = FALSE)
)
Perhaps something custom passed to leaflet in ...?
Lastly, how could a custom JS function display different URLs for each map marker? Consider the example data.frame:
df <- data.frame(url = c("https://stackoverflow.com/questions/tagged/python",
"https://stackoverflow.com/questions/tagged/r")),
lng = c(-122.327298, -122.337298),
lat = c(47.597131,47.587131))
*This was previously asked, but I'm asking the question again here and making a minimal, reproducible example.
from Clicking a leaflet marker takes you to URL
No comments:
Post a Comment