防止缩小R-Map单张吗? [英] Prevent zooming out in leaflet R-Map?

查看:90
本文介绍了防止缩小R-Map单张吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用传单R-package制作了传单地图.

I made a leaflet map with the leaflet R-package.

结果如下所示:

我对此非常满意,但是当我将其嵌入网站并用笔记本电脑向下滚动文章时,我常常不小心缩小了地图,看起来像这样:

I am very happy with it, but when I embed it into a website and scroll down the article with my laptop I often accidentally zoom out of the map which then looks like this:

用户也必须放大地图,看看地图的引导部分,这确实让我很烦.

The user have to zoom back in too have a look at the intersteing part of the map which really annoys me.

是否可以像平常一样放大地图,但不能像在图像上那样放大地图,从而冻结地图的一部分?我尝试在代码中设置视图",但是您仍然可以缩小视图,因此我删除了该部分.

Is there a way to freeze the part of the map like you can zoom in as usual but can't zoom out more than like on the image? I tried setting the View in my code but you still can zoom out so I deleted that part.

    mymap <- leaflet() %>% 

addProviderTiles("Esri.WorldGrayCanvas") %>%
addPolygons(data = dortmund, 
            fillColor = ~palette(student1$Anteil),  ## we want the polygon filled with 
            ## one of the palette-colors
            ## according to the value in student1$Anteil
            fillOpacity = 0.6,         ## how transparent do you want the polygon to be?
            color = "darkgrey",       ## color of borders between districts
            weight = 1.5,            ## width of borders
            popup = popup1,         ## which popup?
            group="<span style='color: #7f0000; font-size: 11pt'><strong>2000</strong></span>")%>%  
            ## which group?
            ## the group's name has to be the same as later in "baseGroups", where we define 
            ## the groups for the Layerscontrol. Because for this layer I wanted a specific 
            ## color and size, the group name includes some font arguments.  

## for the second layer we mix things up a little bit, so you'll see the difference in the map!
addPolygons(data = dortmund, 
            fillColor = ~palette(student2$Anteil), 
            fillOpacity = 0.2, 
            color = "white", 
            weight = 2.0, 
            popup = popup2, 
            group="2014")%>%
addLayersControl(
    baseGroups = c("<span style='color: #7f0000; font-size: 11pt'><strong>2000</strong></span>", ## group 1
                   "2014" ## group 2
    ),
    options = layersControlOptions(collapsed = FALSE))%>% ## we want our control to be seen right away
addLegend(position = 'topleft', ## choose bottomleft, bottomright, topleft or topright
           colors = c('#fee0d2',
                      '#fcbba1',
                      '#fc9272',
                      '#fb6a4a',
                      '#ef3b2c',
                      '#cb181d',
                      '#a50f15',
                      '#67000d'), 
           labels = c('0%',"","","","","","",'26%'),  ## legend labels (only min and max)
           opacity = 0.6,      ##transparency 
           title = "relative<br>amount")   ## title of the legend

原谅我的英语水平很差.如果回答我的问题很重要,请在此处查看完整代码: http://journocode.com/2016 /01/28/your-first-choropleth-map/.

Forgive my bad english skills. If it's important to answer my question, full code's here: http://journocode.com/2016/01/28/your-first-choropleth-map/.

非常感谢您

推荐答案

用以下内容替换addProviderTiles(设置想要的最大和最小缩放级别:

Replace your addProviderTiles with the following (set whatever zoom levels you want for max and min:

addProviderTiles("Esri.WorldGrayCanvas",
        options = providerTileOptions(minZoom=10, maxZoom=18))

这篇关于防止缩小R-Map单张吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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