如何将名称添加到折线的中心?我添加了一段代码:
为了使示例位于底部,我必须在哪里放置什么代码?文本应始终存在,没有弹出窗口,隐藏或悬停。
对于主题图,在addPolylines上只是tm_text(“ county”)。预先感谢!
leaflet() %>%
addProviderTiles("CartoDB.Positron") %>%
addMarkers(
lng= 125.781199, lat= 39.039555,
label="fun",
labelOptions = labelOptions(noHide = FALSE, direction = "bottom", offset=c(0,5))) %>%
addPolygons(data=data,
stroke=FALSE,
smoothFactor = 0.2,
fillOpacity = 0.8,
label = lapply(list, HTML),
color= ~pal(data$data)) %>%
addPolylines(data = county,
fillColor = "transparent",
color = "#000000",
stroke = TRUE,
weight = 1.5,
smoothFactor = 0.5,
group = "county") %>%
addLegend(position = "topright",
pal = pal,
values = data$data,
title = "",
opacity = 1,
labFormat = labelFormat(suffix = " %",
transform = function(x) 100 * x))
答案 0 :(得分:0)
我认为您不能直接使用addPolygons()
来完成此操作,但是您可以覆盖纯文本图层。请查看How to add labels on top of polygons in leaflet的答案,其中有完整的示例。
摘要如下:
addLabelOnlyMarkers()