Increase height of leaflet map inside modal

I created a toy app that is an interactive map in which you click on a point, then the app buffers around that point by 5 degrees and then displays a raster (cropped to the buffer) overlaid on another leaflet map inside of a modal. The problem is that the modal is not tall enough. I'd like the modal to fill ~80% of the height dimension of the screen with 'height: hv85', or similar, but don't know where to put this.

App here:

library(leaflet)
library(shiny)
library(raster)

ppt_ll <-
  getData('worldclim', var = 'prec', res = 10) #dowload coarse resolution precip normal data
ppt_sum <- sum(ppt_ll) #sum throughout year

ui <-  fillPage(
  leafletOutput("main_map", height = '100%'),
  uiOutput("modal_map", width = '100%', height = '100%') #want to increase height of output modal to fill most of screen
)

server <- function(input, output) {
  output$main_map <- renderLeaflet({
    # base map
    map <- leaflet() %>%
      addProviderTiles("Esri.WorldImagery")
    map
  })
  
  observe({
    click <- input$main_map_click #if somebody clicks on map...
    if (is.null(click))
      return()
    
    click_xy <-
      SpatialPoints(
        coords = data.frame(click$lng, click$lat),
        proj4string = CRS('+init=epsg:4326')
      )
    
    if (!is.na(extract(ppt_sum, click_xy))) { #make sure you don't click outside of raster extent
      
      bb <- extent(
        click_xy@coords[, 1] - 5,
        click_xy@coords[, 1] + 5,
        click_xy@coords[, 2] - 5,
        click_xy@coords[, 2] + 5
      )
      
      bounded_ppt_sum <-
        crop(ppt_sum, bb) #...crops a 5 degree buffer around clicked point
      
      ppt_wm <-
        projectRasterForLeaflet(bounded_ppt_sum, method = 'bilinear') #projects for leaflet
      
      pal <- colorNumeric(
        palette = 'Spectral',
        domain = values(ppt_wm),
        na.color = 'transparent'
      )
      
      popup_map <- leaflet() %>% #make a leaflet map to go in modal
        addProviderTiles("Esri.WorldImagery") %>%
        addRasterImage(ppt_wm) %>%
        addLegend(pal = pal,
                  values = values(ppt_wm),
                  title = 'Average total ppt')
      
      output$modal_map <- #render modal with leaflet sub-map of precip layer inside
        renderUI({
          showModal(
            modalDialog(renderLeaflet({
              popup_map
            }),
            size = 'l', #nope, not big enough!
            title = 'Help! I am trapped in a really short modal!')
          )
        })
    }
    
    
  })
}
  
shinyApp(ui = ui, server = server)

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.