I'm using the R package leaftlet to create a map with some markers, but I also need to show the GPS position on the map for movile devices.
I know that this is possible in leaflet with the location method and some javascript but it seems that this method is not available in the R package: "leaflet".
What is the best way to show the GPS position in a map generated with R and leaflet?
Important: Open the map in a browser not inside RStudio! And allow the request for location access!
library(leaflet)
library(leaflet.extras)
map <- leaflet() %>% addTiles()
map <- addControlGPS(map, options = gpsOptions(position = "topleft", activate = TRUE,
autoCenter = TRUE, maxZoom = 10,
setView = TRUE))
activateGPS(map)
Very cool feature, thanks for the question!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With