我想从R Plotly地图箱图例或工具提示文本链接到另一个站点。能做到吗?
以下是一些示例代码。在运行之前,您将需要一个mapbox令牌。另外,如果您从RStudio中“显示在新窗口中”,地图将呈现。
library(plotly)
Sys.setenv('MAPBOX_TOKEN' = 'your_mapbox_token_here')
dat <- map_data("world", "canada") %>% group_by(group)
p <- plot_mapbox(dat, x = ~long, y = ~lat,
name = '<a href="https://facebook.com">This is a link</a>') %>%
add_paths(size = I(2)) %>%
add_segments(x = -100, xend = -50, y = 50, 75) %>%
layout(mapbox = list(zoom = 0,
center = list(lat = ~median(lat),
lon = ~median(long))
))
p