r - 如何使用 leaflet.extras addControlGPS 获取 GPS 坐标
问题描述
我正在使用Leaflet.extras R 包在地图中添加 Gps 控件。我在代码中使用了扩展addControlGPS:
... %>%
addControlGPS(options = gpsOptions(position = "topleft", activate = TRUE,
autoCenter = TRUE, maxZoom = 60,
setView = TRUE)) %>%
...
控制器工作正常。
我需要提取 Gps 坐标以在我的代码中重新用作其他函数的参数。有什么办法吗?
解决方案
每次 gps 位置更新时,坐标都会写入map.id+'_gps_located'
. 您可以在他们的 gitleaflet.extras
中的 htmlwidgets/bindings文件夹中找到所有绑定。
工作示例
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)
推荐阅读
- angular - 无法读取未定义的属性“数量”
- react-native - 使用模拟器为 ReactNative 实现 CodePush
- maven - 使用 Maven 构建依赖项目
- maven - 执行 Maven 构建时 Maven 跳过生成报告
- javascript - 构建应用程序时,装饰器 NgRx/Effects 不支持函数调用
- jquery - 用选择菜单替换文本
- c# - 如何将连续流发送到 ASP Core REST API
- sql - (从 [payment] 中选择 [amount] 其中 ([payment_account] = '确认存款') and ([action] = 'Received') and ([amount] = '95'))
- sql - SQL插入SQLRPGLE后无法更新文件
- json - Ktor:在多平台中以 List 为根序列化/反序列化 JSON