在 rShiny 应用程序中使用 markerClusterOptions() 时的传单弹出窗口

Leaflet popup when using markerClusterOptions() in an rShiny app

我的困难是当使用 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)

挑战截图。

一种选择是通过在 markerClusterOptions 上添加 spiderfyDistanceMultiplier 来增加距蜘蛛标记放置中心的距离,例如:

clusterOptions = markerClusterOptions(spiderfyDistanceMultiplier=1.5)

https://github.com/Leaflet/Leaflet.markercluster#customising-the-clustered-markers