SymbolixAU / googleway

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

fullscreen map not responsive #211

Open I3auke opened 4 years ago

I3auke commented 4 years ago

Hi, I would expect to create a responsive fullscreen map in shiny via:

# ui <- fluidPage(
#   google_mapOutput(outputId = "map", height = "100%")
# )

But it is not working (map is not loading at all; only search box is visible). "height ='800px'" does look better, but it is not responsive (it does not respond when window is resized).

thnx. Bauke

SymbolixAU commented 4 years ago

Can you post the full shiny code please (you can omit the api key)?

I3auke commented 4 years ago

see below. I tried omitting "height = '100%'" and changing it to 'auto' but without the desired result. thnx!

library(shiny)
library(googleway)
library(shinydashboard)

ui <- fluidPage(google_mapOutput("map",height = '100%'))
latitude<-c(50.814,51.953)
longitude<-c(3.6345, 4.567)
markers <- data.frame(latitude=latitude,longitude=longitude)

server <- function(input, output, session){
  map_key <- "XXXXXX"
  output$map <- renderGoogle_map({
    map<-google_map(key = map_key, data = markers,
                    search_box = TRUE, fullscreen_control = TRUE) %>%
      add_markers()
    map
  })
}

shinyApp(ui, server)
SymbolixAU commented 4 years ago

Thanks - I can replicate the issue.

We are getting a google is not defined javascript error.

I'll look into it.

Screen Shot 2019-11-12 at 8 45 08 am

SymbolixAU commented 4 years ago

"height ='800px'" does look better, but it is not responsive (it does not respond when window is resized).

But I'm not seeing this behaviour.

I3auke commented 4 years ago

found a workaround:

ui <- bootstrapPage(
  tags$style(type = "text/css", "html, body {width:100%;height:100%}"),
  google_mapOutput("map",width = "100%", height = "100%"))

works well

jimbrig commented 3 years ago

did you ever find a solution for the uncaught reference error?

image

dcooley commented 3 years ago

nope...

I kind of let it slide given the workaround. Have you tried the proposed solution ?

jimbrig commented 3 years ago

yes and it caused my map to not render when I set height to "100%". Does it require bootstrapPage?

I am using shinydashboardPlus, and my map is in a held within a box > fluidRow > column width 6.

jimbrig commented 3 years ago

scratch that. simply changing height to 400px worked.

This is all I changed:

image

Pretty weird given that the default arguments already use 100% and 400px for width and height:

google_mapOutput
function (outputId, width = "100%", height = "400px") 
{
    htmlwidgets::shinyWidgetOutput(outputId, "google_map", 
        width, height, package = "googleway")
}

Thanks though! Glad I found this thread, feels good finally getting those console errors down to zero in an enormous app! 💪