I do not have a ggmap API Key, but it works the same way. You all do that with CSS
.
You have to set the body height and width of 100%, same applies for the plot so they extend to the width and height of the viewport.
Everything on top of that has to be set to position: absolute
. This means the div will be 10px away from the top and 10px away from the right. absolutePanel
does this setting for you, but you could do it in your own css.
library(shiny)
library(leaflet)
library(RColorBrewer)
library(ggmap)
ui <- bootstrapPage(
tags$style(type = "text/css", "html, body {width:100%;height:100%}"),
plotOutput("map", width = "100%", height = "100%"),
absolutePanel(top = 10, right = 10,
sliderInput("range", "Magnitudes", min(quakes$mag), max(quakes$mag),
value = range(quakes$mag), step = 0.1
),
selectInput("colors", "Color Scheme",
rownames(subset(brewer.pal.info, category %in% c("seq", "div")))
),
checkboxInput("legend", "Show legend", TRUE)
)
)
server <- function(input, output, session) {
output$map <- renderPlot({
df <- data.frame(
gp = factor(rep(letters[1:3], each = 10)),
y = rnorm(30)
)
ds <- do.call(rbind, lapply(split(df, df$gp), function(d) {
data.frame(mean = mean(d$y), sd = sd(d$y), gp = d$gp)
}))
ggplot(df, aes(gp, y)) +
geom_point() +
geom_point(data = ds, aes(y = mean), colour = 'red', size = 3)
})
}
shinyApp(ui, server)