代码之家  ›  专栏  ›  技术社区  ›  JeanBertin

使用R googlemap包按簇收集标记

  •  2
  • JeanBertin  · 技术社区  · 6 年前

    如何使用R在Google Maps中对标记进行聚类 googleway 包裹

    我尝试使用add\u markers(“cluster=TRUE”)选项,但没有成功

    下面是一个可复制的示例和我得到的地图:

    library(googleway)
    
    key <- "my_google_map_API"
    df <- data.frame(
        lat = c(45.77740319999999,45.77740319999999,46.77740319999999,46.77740319999999),
        lon = c(4.855214400000023,4.955214400000023,4.855214400000023,4.955214400000023))
    
    google_map(key = key, height = 600, search_box = T) %>% 
        add_markers(data = df,cluster = TRUE)
    

    enter image description here

    非常感谢你

    1 回复  |  直到 6 年前
        1
  •  1
  •   SymbolixAU Adam Erickson    6 年前

    A bug 在CRAN的最新版本(v2.4)中发现,这打破了集群。

    我在开发版本(v2.5+)中发布了一个修复程序,您可以使用它来安装

    # library(devtools)
    devtools::install_github("SymbolixAU/googleway")
    

    那么它应该会起作用。

    library(googleway)
    key <- "map_key"
    
    df <- data.frame(
        lat = c(45.77740319999999,45.77740319999999,46.77740319999999,46.77740319999999),
        lon = c(4.855214400000023,4.955214400000023,4.855214400000023,4.955214400000023)
        )
    
    google_map(key = key, height = 600, search_box = T) %>% 
        add_markers(data = df,cluster = TRUE)
    

    enter image description here