我在 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))
但问题是,你几乎看不到每个城市的“标签”:
我想让“标签”更加明显,像这样:
我尝试使用“重量”和“不透明度”参数,但这似乎不起作用。
有人可以告诉我该怎么做吗?
注意:我不想在 R SHINY 中执行此操作,只是在 R 中使用 LEAFLET。
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))