Learn R Programming

toro (version 0.1.0)

toggle_lat_lng_grid: Show/hide the latitude and longitude grid on the map

Description

Show/hide the latitude and longitude grid on the map

Usage

toggle_lat_lng_grid(proxy, show = TRUE)

Value

The map proxy object for chaining.

Arguments

proxy

The map proxy object created by mapProxy().

show

Logical indicating whether to show or hide the grid. Default is TRUE.

Examples

Run this code
if(interactive()){
library(shiny)
library(toro)

ui <- fluidPage(
 tagList(
   mapOutput("map"),
   actionButton("show_grid", "Show Grid"),
   actionButton("hide_grid", "Hide Grid")
 )
)
server <- function(input, output, session) {

 output$map <- renderMap({
   map() |>
     add_lat_lng_grid()
  })

  observe({
    mapProxy("map") |>
      toggle_lat_lng_grid(show = TRUE)
  }) |>
    bindEvent(input$show_grid)

  observe({
    mapProxy("map") |>
      toggle_lat_lng_grid(show = FALSE)
   }) |>
     bindEvent(input$hide_grid)
}
}

Run the code above in your browser using DataLab