防止在传单 R-Map 中缩小? [英] Prevent zooming out in leaflet R-Map?

查看:15
本文介绍了防止在传单 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天全站免登陆