将noUiSlider添加到R Leaflet地图

时间:2018-10-09 14:39:51

标签: r leaflet nouislider

我试图将noUiSlider添加到R的Le​​aflet地图中,但没有运气,滑块根本没有出现。似乎onRender函数无法访问noUiSlider,但我不知道为什么。

任何想法或指示都将不胜感激。谢谢!

map <- leaflet() %>% addTiles 
# add NoUISlider to map.
map$dependencies[[length(map$dependencies)+1]] <- htmlDependency(
  name = 'noUiSlider',
  version = "11.1.0",
  src = c(href = 'Leaflet/'),
  script = "nouislider.js",
  stylesheet = "nouislider.css"
)

#autozoom to state or world map upon base group selection
map <- map %>%
  onRender("

    function(el, x) {
    var map = this;
    // Add in slider

    var slider = document.getElementById('slider');
    noUiSlider.create(slider, {
    start: filters.range,
    tooltips: true,
    connect: [true, false],
    range: {
    'min': 2016,
    'max': 2018
    }
    });
    slider.addTo(HTMLWidgets.find('.leaflet'));
  }")

0 个答案:

没有答案