【问题标题】:Disabling zooming when scrolling over leaflet map in R在R中滚动传单地图时禁用缩放
【发布时间】:2019-09-24 13:15:57
【问题描述】:

我想在将鼠标悬停在 R 中的传单地图上时禁用缩放。

我尝试了leaflet.extras 包和leaflet(options = leafletOptions(scrollWheelZoom = FALSE)) 中的suspendScroll(hoverToWake = FALSE) 函数,但都不起作用。

leaflet(width = "100%") %>%
  setView(0, 0, 1) %>%
  addTiles() %>%
  suspendScroll(hoverToWake = FALSE)

当我将鼠标悬停在地图上并开始滚动时,地图仍在放大和缩小。我是唯一有这个问题的人吗?我的 R 版本是 3.6.1

【问题讨论】:

  • unfotunatly 不是,因为它只在使用传单 javascript 时才这样工作,我在 R 中使用传单

标签: r r-leaflet


【解决方案1】:

如果要禁用所有缩放,可以将minZoommaxZoom 设置为与setView 中的zoom 相同的数字。就像这个可重现的例子:

map <- leaflet(options = leafletOptions(minZoom = 10, maxZoom = 10)) %>% 
addTiles() %>% 
setView(lng = 7.35, lat = 50.05, zoom = 10)
map

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-27
    • 2011-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多