我在 Shiny 的应用程序中使用传单,我想获取有关我单击的标记的信息。在这一点上,我有一个带有标记的漂亮 map ,但是如何返回有关我单击的标记的信息?
我的服务器.R
library(shiny)
library(leaflet)
library(rgdal)
setwd("~/github/shiny_stuff/banyuls_map/")
####load data converted in geojson
capteurs<-readOGR("./data/capteurs.geojson", "OGRGeoJSON")
shinyServer(function(input, output, session) {
map <- createLeafletMap(session, "map")
session$onFlushed(once=TRUE, function() {
map$addMarker(capteurs@coords[,2],
capteurs@coords[,1]
)
})
})
我的用户界面
library(shiny)
library(leaflet)
shinyUI(fluidPage(
titlePanel("title panel"),
leafletMap(
"map", "100%", 400,
initialTileLayer = "//{s}.tiles.mapbox.com/v3/jcheng.map-5ebohr46/{z}/{x}/{y}.png",
initialTileLayerAttribution = HTML('Maps by <a href="http://www.mapbox.com/">Mapbox</a>'),
options=list(
center = c(42.4797, 3.1181),
zoom = 12
)
),
))
最佳答案
我相信你想看看:
input$map_marker_click
示例 bquast 引用使用
input$map_shape_click
但这基于包含在您加载的 LeafletMap 中的底层 GeoJSON 数据。您可以使用
map_marker_click
返回的信息查询您的数据并将其插入弹出窗口。
关于r - 如何使用传单读取 Shiny 的标记数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26104933/