我正在使用 leaftlet.extras R 包在 map 中添加 Gps 控件。 我在我的代码中使用扩展 addControlGPS :
... %>%
addControlGPS(options = gpsOptions(position = "topleft", activate = TRUE,
autoCenter = TRUE, maxZoom = 60,
setView = TRUE)) %>%
...
Controller 工作正常。
我需要提取 Gps 坐标以在我的代码中重新用作其他函数的参数。有什么办法吗?
最佳答案
每次 gps 位置更新时,坐标都会写入 map.id+'_gps_located'
。您可以在 htmlwidgets/bindings 中找到所有 leaflet.extras
绑定(bind)在他们的 git 文件夹中。
工作示例
library(leaflet)
library(leaflet.extras)
library(shiny)
ui <- fluidPage(
leafletOutput('map')
)
server <- function(input, output, session) {
output$map <- renderLeaflet({ leaflet()%>%addTiles() %>%
addControlGPS(options = gpsOptions(position = "topleft", activate = TRUE,
autoCenter = TRUE, maxZoom = 60,
setView = TRUE))})
observe(
print(input$map_gps_located)
)
}
shinyApp(ui, server)
关于r - 如何使用 leaflet.extras addControlGPS 获取 GPS 坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55557752/