SymbolixAU / googleway

R Package for accessing and plotting Google Maps
http://symbolixau.github.io/googleway/
Other
234 stars 46 forks source link

Error with add_heatmap #189

Closed tradeli closed 5 years ago

tradeli commented 5 years ago

EDIT: I'm running R3.5.1, RStudio 1.1.4, Windows 10, Google Chrome 71

When I try to plot markers, it works just fine. But if I try to plot a heat map, it gives the error in the image below and nothing is plotted on the map:

error_maps

No matter how many times I try to press F5 or forced reload, it still gives the same problem.

The code I'm using is this:

ui <- fluidPage(google_mapOutput(outputId = "map"))

server <- function(input, output) {
  map_key = MY_KEY#Here I replace the MY_KEY with my actual google maps key

  output$map <- renderGoogle_map({
    tabelaDadosCidadesCandidatas = data.table(
      latitude = c(-27.68970, -9.18564, -16.46420),
      longitude = c(-51.1271, -43.0494, -49.9617)
    )

    add_heatmap(
      map = google_map(
        width = '100%',
        height = '100%',
        fullscreen_control = TRUE,
        street_view_control = FALSE,
        map_type_control = FALSE,
        search_box = FALSE,
        key = map_key
      ),
      data = tabelaDadosCidadesCandidatas,
      lat = "latitude",
      lon = "longitude",
      option_radius = 0.001
    )
  })

}

shinyApp(ui = ui, server = server)
SymbolixAU commented 5 years ago

yeah there's something strange going on when in Shiny, because this works on its own

    add_heatmap(
      map = google_map(
        # width = '100%', 
        # height = '100%',
        fullscreen_control = TRUE,
        street_view_control = FALSE,
        map_type_control = FALSE,
        search_box = FALSE,
        key = map_key
      ) ,
      data = tabelaDadosCidadesCandidatas,
      lat = "latitude",
      lon = "longitude",
      option_radius = 10
    )

I'll have a look into it and let you know.

SymbolixAU commented 5 years ago

I've just pushed a commit to the dev version to check the charts library is loaded in a shiny environment. Could you install it and let me know if it works for you?

devtools::install_github("SymbolixAU/googleway")

Then you should see (I changed the option_radius to 10 in this example)

shinyApp(ui = ui, server = server)

screen shot 2018-12-27 at 11 29 30 am

tradeli commented 5 years ago

It worked!!!!!!!!!!!!! Thank you very much!