在 R Leaflet 地图中制作更多“引人注目”的标签

问题描述 投票:0回答:1

我在 R 中制作了以下地图(来自具有从“1”到“5”排序的 5 个点的数据框):

library(dplyr)
library(leaflet)

map_data <- data.frame("Lat" = c(43.6426, 43.6424, 43.6544, 43.6452, 43.6629), "Long" = c(-79.3871, -79.3860, -79.3807, -79.3806,-79.3957 ), type = c(1,2,3,4,5))
map_data$type = as.factor(map_data$type)


leaflet(map_data) %>% addTiles() %>% addCircleMarkers(stroke = FALSE, label = ~type,
    labelOptions = labelOptions(noHide = TRUE, offset=c(0,-12), fill = TRUE, opacity = 10, weight = 10, textOnly = TRUE))

但问题是,你几乎看不到每个城市的“标签”:

enter image description here

我想让“标签”更加明显,像这样:

enter image description here

我尝试使用“重量”和“不透明度”参数,但这似乎不起作用。

有人可以告诉我该怎么做吗?

注意:我不想在 R SHINY 中执行此操作,只是在 R 中使用 LEAFLET。

参考: 在 Rshiny 传单的圆形标记上打印标签

r visualization geospatial r-leaflet
1个回答
2
投票

fillOpacity = 
之前
labelOptions

library(dplyr)
library(leaflet)

map_data <- data.frame("Lat" = c(43.6426, 43.6424, 43.6544, 43.6452, 43.6629), "Long" = c(-79.3871, -79.3860, -79.3807, -79.3806,-79.3957 ), type = c(1,2,3,4,5))
map_data$type = as.factor(map_data$type)

leaflet(map_data) %>% 
  addTiles() %>% 
  addCircleMarkers(stroke = FALSE, 
    label = ~type, 
    fillOpacity = 0.9, 
    labelOptions = labelOptions(noHide = TRUE, fill = FALSE, offset = c(5,2), textsize = "18px", textOnly = TRUE))

© www.soinside.com 2019 - 2024. All rights reserved.