leaflet icon indicating copy to clipboard operation
leaflet copied to clipboard

Add lat lon coords to mini map leaflet rshiny

Open lime-n opened this issue 2 years ago • 0 comments

I have posted the following question on stackoverflow and the community expect this to be a bug: Add lat lon coords to mini map leaflet rshiny.

Please can you clarify, also, I'll post the code here:

library(shiny)
library(leaflet)
library(tidyverse)

ui <- fluidPage(
  leafletOutput('map')
)
list_of_inputs <- c()
server <- function(input, output, session) {
  output$map <- renderLeaflet({
    latitude <- c(53.380909, 53.371566)
    longitude <- c(-1.486197, -1.577604)
    placeNames <- c("Hicks Building", "The Sportsman")
    leaflet(options=leafletOptions(zoomControl = FALSE)) %>%
      setView(lng = -1.525, lat = 53.38, zoom =12) %>%
      addProviderTiles(provider = leaflet.providers::providers_default()$providers$Esri.WorldStreetMap) %>%
      addMarkers(lat = latitude,
                 lng = longitude,
                 popup = placeNames)
    })
  observeEvent(input$map_marker_click, {
    click = input$map_marker_click
    leafletProxy('map')%>%addMiniMap(zoomLevelFixed = 14, centerFixed = c(click$lat, click$lng))

  })

}

shinyApp(ui, server)

lime-n avatar Mar 11 '23 11:03 lime-n