How to “save” click events in Leaflet Shiny map

走远了吗. 提交于 2019-11-28 13:40:20

You can do this using reactiveValues to store the clicks.

Right at the top of your server function add

RV<-reactiveValues(Clicks=list())

and then change your observeEvent to:

observeEvent(input$map_shape_click, {

      #create object for clicked polygon
      click <- input$map_shape_click
      RV$Clicks<-c(RV$Clicks,click$id)
      print(RV$Clicks)

 }) #END OBSERVE EVENT

What happens is every time you click, the id is appended to the list of clicks stored in RV$Clicks. This does not have to be a list you could make it a vector if that is better for you.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!