gpt4 book ai didi

r - 传单标签重叠修复 - leaflet::addMarkers

转载 作者:行者123 更新时间:2023-12-02 02:39:04 25 4
gpt4 key购买 nike

我正在寻找使用 R 函数 leaflet::addMarkers 时重叠标签的修复方法。

long <- c(147.768, 147.768, 147.768,147.768, 147.768, 147.768)
lat <- c(-36.852, -36.852, -36.852,-36.852, -36.852, -36.852)
label <- c('long label1', 'long label2', 'long label3','long label4', 'long label5', 'long label6')

markers <- data.frame(lat,long,label)


leaflet() %>%
addTiles() %>% # Add default OpenStreetMap map tiles
addMarkers(lng=markers$long, lat= markers$lat,
popup="The birthplace of R",
label = markers$label,
labelOptions = labelOptions(noHide = T, direction = 'auto'),
clusterOptions = markerClusterOptions()
)

最佳答案

您可以在labelOptions中设置noHide = F而不是noHide = T

您可以尝试添加 options =markerOptions(riseOnHover = TRUE) 以使标签位于标记顶部。

最终代码为:

leaflet() %>%
addTiles() %>% # Add default OpenStreetMap map tiles
addMarkers(lng=markers$long, lat= markers$lat,
popup="The birthplace of R",
label = markers$label,
labelOptions = labelOptions(noHide = F, direction = 'auto'),
options = markerOptions(riseOnHover = TRUE),
clusterOptions = markerClusterOptions()
)

关于r - 传单标签重叠修复 - leaflet::addMarkers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46409300/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com