Shiny, leaflet & addSearchOSM : how to retrieve lat/long

I have a leaflet map inside a Shiny app. I have JS code that captures the user's location and assigns it to input$lat and input$long. The leaflet map adds a Circle Marker that defaults to the user's location.

The leaflet.extras::addSearchOSM function adds a search magnifying glass to the map. A user can search an address, and the circle marker will move to that address. What I want to do, is retrieve the latitude and longitude of the searched address, assign lat/long to objects in the workspace, and display in the app. I don't know how to retrieve the lat/long that is geocoded from the OSM address.

output$map <- renderLeaflet({ leaflet() %>% addTiles() %>% addCircleMarkers(lat=input$lat,lng=input$long,radius=10,color='blue') %>% leaflet.extras::addSearchOSM() })

1 Like

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.