我用传单 R 包制作了传单 map 。
结果如下:
我对它非常满意,但是当我将它嵌入网站并用笔记本电脑向下滚动文章时,我经常不小心将 map 缩小,然后看起来像这样:
用户也必须放大回来看看 map 的中间部分,这真的让我很恼火。
有没有办法卡住 map 的一部分,就像你可以像往常一样放大但不能像图像那样缩小?我尝试在我的代码中设置 View ,但您仍然可以缩小,所以我删除了该部分。
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/ .
非常感谢
最佳答案
将您的 addProviderTiles 替换为以下内容(设置您想要的最大和最小缩放级别:
addProviderTiles("Esri.WorldGrayCanvas",
options = providerTileOptions(minZoom=10, maxZoom=18))
关于r - 防止缩小传单 R-Map?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35556197/