r - 如何使用传单读取 Shiny 的标记数据

标签 r leaflet shiny

我在 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
    )
  ),



))

enter image description here

最佳答案

我相信你想看看:

input$map_marker_click

示例 bquast 引用使用 input$map_shape_click但这基于包含在您加载的 LeafletMap 中的底层 GeoJSON 数据。

您可以使用map_marker_click返回的信息查询您的数据并将其插入弹出窗口。

关于r - 如何使用传单读取 Shiny 的标记数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26104933/

相关文章:

r - 在 data.table 上按周期分组重复

r - 添加表格(对齐的文本 block )以在 R 中绘图

r - 更改 ggplot 凹凸图上的文本大小

javascript - R - 使用 DT 按行格式化

r - 如何根据上一行中的月份连续增加一个月?

javascript - 有什么方法可以在 Leaflet 上绘制路径(多段线),宽度/笔划以米而不是像素为单位?

node.js - 运行时错误 : Cannot find module "leaflet.awesome-markers" Ionic 3

javascript - 循环传单中的数据

r - 菜单项周围的条件面板无法正确显示

r - 使用 purrr::walk 来设置多个事件观察者