3

In R, I would like to create a popup when hovering over a polyline that has been added to a leaflet map.

Below is some code to create three random polylines on a map.

library(leaflet)
library(dplyr)
m = leaflet() %>% addTiles()
rand_lng = function(n = 10) {rnorm(n, -93.65, .01)}
rand_lat = function(n = 10) {rnorm(n, 42.0285, .01)}
m %>% addPolylines(
  c(rand_lng(10), NA, rand_lng(10), NA, rand_lng(10)),
  c(rand_lat(10), NA, rand_lat(10), NA, rand_lat(10)),
  color = c('red', 'green', 'blue'),
  fill=FALSE, weight=2
)

I would like a different popup to occur when hovering over each of the lines.

The options argument looks useful, especially combined with popupOptions() but I don't see much on the hover options, and do not quite not how to integrate it.

Any help would be much appreciated.

h.l.m
  • 13,015
  • 22
  • 82
  • 169
  • Did you ever find a solution for this problem? – jalapic Jan 08 '16 at 18:33
  • @jalapic, see http://stackoverflow.com/questions/30964020/popup-when-hover-with-leaflet-in-r/36984950#36984950 for an alternative solution to a similar problem – MLavoie May 02 '16 at 14:31

0 Answers0