[R-3.4.3 64 位、RStudio、shinydashboard_0.6.1、shiny_1.0.5、leaflet.extras_0.2、Chrome]
我正在制作在 R/Leaflet 中使用 Shiny 的图标,我得到的所有内容如下,但我不知道为什么:
这是使用玩具示例来自这里 http://rstudio.github.io/leaflet/markers.html:
oceanIcons <- iconList(
ship = makeIcon("ferry-18.png", "[email protected] /cdn-cgi/l/email-protection", 18, 18),
pirate = makeIcon("danger-24.png", "[email protected] /cdn-cgi/l/email-protection", 24, 24)
)
# Some fake data
df <- sp::SpatialPointsDataFrame(
cbind(
(runif(20) - .5) * 10 - 90.620130, # lng
(runif(20) - .5) * 3.8 + 25.638077 # lat
),
data.frame(type = factor(
ifelse(runif(20) > 0.75, "pirate", "ship"),
c("ship", "pirate")
))
)
leaflet(df) %>% addTiles() %>%
# Select from oceanIcons based on df$type
addMarkers(icon = ~oceanIcons[type])
以及以下,具有不同但相似的玩具数据,使用时runApp(shinyApp(ui, server), launch.browser = TRUE)
;