闪亮的R传单的区域选择事件 [英] Area select event for R leaflet in shiny

查看:61
本文介绍了闪亮的R传单的区域选择事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用以下代码在传单中使用了鼠标单击事件:

I've played with the mouse click event in leaflet using the following code:

mymap=leaflet()
selected_site=eventReactive(input$mymap_marker_click,{
      event <- input$mymap_map_marker_click
      return(mydt[Long==event$lng & Lat==event$lat,get("sites")])
    })

单击地图上的某个点后,显示data.table中的图. 现在,我想选择一个整个区域,然后显示与其绑定的数据.

to display a plot from a data.table after a click on a point of the map. Now, I'd like to select an entire area then display data binding to it.

换句话说,我不想选择几个(Lat,Long),而是选择一系列(Lat1,Long1)....(Latn,Longn)

In other terms, I'd like to select not a couple of (Lat,Long) but a series of (Lat1, Long1)....(Latn,Longn)

在传单中有这样做的意思吗?

Is there a mean to do it in leaflet ?

预先感谢

推荐答案

您只需要在每个区域实例化L.Polygon并将一个事件处理程序附加到该区域即可:

You just have to instantiate a L.Polygon per area, and attach an event handler to it: http://playground-leaflet.rhcloud.com/zab/edit?html,console,output

请记住,您可以使区域透明(不透明度为零,但fill选项仍设置为true)并仍然从中获取鼠标事件.

Keep in mind that you can make areas transparent (zero opacity but fill option still set to true) and still get mouse events from them.

这篇关于闪亮的R传单的区域选择事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆