我正在使用leaftlet.extras R 包在地图内添加 Gps 控件。我在代码中使用扩展addControlGPS :
... %>%
addControlGPS(options = gpsOptions(position = "topleft", activate = TRUE,
autoCenter = TRUE, maxZoom = 60,
setView = TRUE)) %>%
...
Run Code Online (Sandbox Code Playgroud)
控制器工作正常。
我需要提取 Gps 坐标以在代码中重新用作其他函数的参数。有什么办法可以做到这一点吗?
每次 GPS 位置更新时,坐标都会写入map.id+'_gps_located'
. 您可以在git 的htmlwidgets/bindings文件夹中找到所有leaflet.extras
绑定 。
工作示例
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)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1445 次 |
最近记录: |