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?

4

1 回答 1

2

这是一个如何做到这一点的示例。

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)

popupIframe函数当前未矢量化,因此我们需要使用lapply在列表中创建弹出对象。

于 2018-04-13T07:27:01.590 回答