我的困难是,当使用 markerClusterOptions() 时,无法单击最接近爆炸圆的点。远离集群标记的点没有问题。在下面的示例中,弹出窗口适用于 3 个稍远的标记,但不适用于距离圆北最近的标记。有没有办法设置与集群标记的最小距离或解决这个问题的替代方法?
数据集的表示
b <- structure(list(unique_id = c("jm_1987_sierraleone", "jm_1987_sierraleone",
"jm_1987_sierraleone", "jm_1987_sierraleone"), town_village = c("Yengema",
"Yengema", "Yengema", "Yengema"), classification = c("mastomys natalensis",
"mastomys natalensis", "mastomys natalensis", "mastomys natalensis"
), assay = c("path_1_tested", "path_2_tested", "ab_ag_path_1_positive",
"ab_ag_path_2_positive"), number = c(8, 8, 0, 0), pathogen_tested = c("lassa_mammarenavirus",
"lassa_mammarenavirus", "lassa_mammarenavirus", "lassa_mammarenavirus"
), pa_colour = c("#f1a340", "#f1a340", "#f1a340", "#f1a340"),
lat = c(`12747` = 8.33333301544189, `12748` = 8.33333301544189,
`12749` = 8.33333301544189, `12750` = 8.33333301544189),
lon = c(`12747` = -10.6333332061768, `12748` = -10.6333332061768,
`12749` = -10.6333332061768, `12750` = -10.6333332061768)), row.names = c(NA,
-4L), sf_column = "geometry", agr = structure(c(unique_id = NA_integer_,
town_village = NA_integer_,
classification = NA_integer_, assay = NA_integer_, number = NA_integer_,
pathogen_tested = NA_integer_, pa_colour = NA_integer_,
lat = NA_integer_, lon = NA_integer_), .Label = c("constant",
"aggregate", "identity"), class = "factor"), class = "data.frame")
传单代码
leaflet() %>%
addTiles() %>%
setView(lng = 0, lat = 10, zoom = 5) %>%
addCircleMarkers(data = b,
fillColor = "black",
fillOpacity = 0.3,
stroke = F,
radius = 1) %>%
addCircleMarkers(lng = b$lon,
lat = b$lat,
fillColor = b$pa_colour,
fillOpacity = 0.8,
stroke = F,
radius = 6,
popup = paste0("Study ID: ", b$unique_id,
"<br>",
"Rodent species: ", b$classification,
"<br>",
"Microorganism tested: ", b$pathogen_tested,
"<br>",
"Village/Region: ", b$town_village),
clusterOptions = markerClusterOptions()) %>%
clearControls() %>%
addLegend("topright",
title = "Presence or Absence",
colors = c("#f1a340", "#998ec3"),
labels = c("Absence", "Presence"),
opacity = 0.8)
挑战截图。