2

How do you cluster markers in Google Maps in R using googleway package?

I tried to use the option add_markers("cluster = TRUE ") but without success

Here is a reproducible example and the map that I get:

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

Thank you very much

SymbolixAU
  • 25,502
  • 4
  • 67
  • 139
JeanBertin
  • 633
  • 1
  • 7
  • 23

1 Answers1

1

A bug was found in the latest release version (v2.4) on CRAN which broke the clustering.

I've issued a fix in the development version (v2.5+), which you can install with

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

Then it should work.

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

SymbolixAU
  • 25,502
  • 4
  • 67
  • 139