【发布时间】:2020-08-04 04:10:59
【问题描述】:
看看我的 R 代码,在这里我可以标记两种不同类型的标记图标,但我想用 10 种不同类型的标记图标标记 quakes$mag 列的所有 10 个值。
quakes1 <- quakes[1:10,]
leafIcons <- icons(
iconUrl = ifelse(quakes1$mag < 4.6,
"http://leafletjs.com/examples/custom-icons/leaf-green.png",
"http://leafletjs.com/examples/custom-icons/leaf-red.png"
),
iconWidth = 38, iconHeight = 95,
iconAnchorX = 22, iconAnchorY = 94,
shadowUrl = "http://leafletjs.com/examples/custom-icons/leaf-shadow.png",
shadowWidth = 50, shadowHeight = 64,
shadowAnchorX = 4, shadowAnchorY = 62
)
leaflet(data = quakes1) %>% addTiles() %>%
addMarkers(~long, ~lat, icon = leafIcons)
我尝试使用 switch 语句而不是 ifelse,但它不适用于 switch。
【问题讨论】:
标签: r dictionary leaflet icons markers