shiny leaflet ploygon click event

后端 未结 1 1419
-上瘾入骨i
-上瘾入骨i 2020-12-01 14:38

I have a map called business which is downloaded from natural earth website. What I am doing here is I created a basic Map output which shows the map. I am main

相关标签:
1条回答
  • 2020-12-01 15:40

    The click event in leaflet returns lat, lng and id (and a random value). So you can only access one of those elements.

    The id value relates to the layerId you specify in the shape plotting function, so in your case that's layerId=~admin.

    So you acccess the admin value through the click's id field

    replace p$admin with p$id and you should have your solution.


    If you want to see what's in the click event, just put a print statement around it

    observeEvent(input$Map_shape_click, { # update the location selectInput on map clicks
      p <- input$Map_shape_click
      print(p)
    })
    

    and it will print the object to the console.

    0 讨论(0)
提交回复
热议问题