0

I'm building a map using the mapview R package following this tutorial. Adding a different image to each point using popup=popupImage(images,src = "remote") works fine.

The issue is with iframe popups.

The example using popup = mapview:::popupIframe("https://www.youtube.com/embed/iApz08Bh53w?autoplay=1", width = 300, height = 225) is only for a single point. If I combine several iframe video links (the same way shown with image links) adds ALL video iframes to each point.

How do I add a different iframe to each point?

W148SMH
  • 152
  • 1
  • 11

1 Answers1

2

Here's an example of how this can be done.

library(mapview)

# some example points
pts = breweries[1:2, ]

# some urls - note this cannot be a named list, javascript does not like names!
urls = list(
  "https://www.youtube.com/embed/iApz08Bh53w?autoplay=1",
  "https://www.youtube.com/embed/KEkrWRHCDQU?autoplay=1"
)

# create the popups
pop = lapply(urls, mapview:::popupIframe)

# et voila
mapview(pts, popup = pop)

The popupIframe function is currently not vectorised, hence we need to use lapply to create the popup objects in a list.

TimSalabim
  • 5,604
  • 1
  • 25
  • 36