-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Geolocation #173
Comments
To observe a user's location observeEvent({ input$map_id_geolocation }, { } ) |
I am not able to access the geolocation in this way. I am getting "geolocation.js:23 Uncaught ReferenceError: map_id is not defined at geolocation.js:23" in my browser developer tools. A minimal example is below. I can print from map click, marker drag, etc. but am getting NULL if I try to return the geolocation. Thanks in advance. library(googleway)
library(shiny)
readRenviron('../.Renviron')
ui <- fluidPage(
google_mapOutput("map")
)
server <- function(input, output, session){
output$map <- renderGoogle_map({
google_map(key = Sys.getenv("MAPS_API_KEY"), location = c(38.54, -121.78),
zoom = 8, search_box = TRUE, geolocation = TRUE,
width = '100%', height = '100%'
) %>%
add_markers(data = data.frame(lat = 38.54, lon = -121.78),
draggable = TRUE, update_map_view = FALSE)})
observeEvent(input$map_marker_drag, {
print(input$map_marker_drag)
})
observeEvent(input$map_map_click, {
print(input$map_map_click)
})
#https://github.com/SymbolixAU/googleway/issues/173
observeEvent(input$map_geolocation,{
print(input$map_geolocation)
})
}
shinyApp(ui, server) |
Are you opening this in a browswer, and do you have it set to "allow location" ? |
I am opening it in a Google Chrome browser and I get a pop-up asking if I want to allow it to access my location. I click yes but still nothing happens. |
oh I see, it might need a 'wait until map is ready' before calling the |
Ok this is not quite as straight forward, and I don't know if this worked before, but it's certainly not working now. The
It's working in the browser, but in shiny the 'position' object is empty... $position
named list()
$randomValue
[1] 0.1187743 Ok it's working now shinyApp(ui, server)
Listening on http://127.0.0.1:5590
$lat
[1] -37
$lon
[1] 144
$accuracy
[1] 20
$altitude
NULL
$altitudeAccuracy
NULL
$heading
NULL
$speed
NULL
$timestamp
[1] 1.608248e+12
$randomValue
[1] 0.9922257 |
Thanks for this fix! It seems to be working now. |
https://developers.google.com/maps/documentation/javascript/geolocation
The text was updated successfully, but these errors were encountered: