2016-06-23 78 views
1

我想在我的R Leaflet地圖中設置縮小最大值。我按照Prevent zooming out in leaflet R-Map?中的上一個問題/回答的示例進行操作,但它不起作用。該線應該能夠做到這一點是:R小冊子:縮放控制級別

options = providerTileOptions(minzoom = 1, maxzoom = 10)) 

你們可以幫我找出原因嗎?

這裏是代碼:

deck_lf_par_map <- leaflet(lpoints) %>% 
       addPolygons(data = dio, noClip=T, 
          weight = 4, 
          dashArray="5, 1", 
          color = "black", 
          fillOpacity = .01, 
          smoothFactor = 0) %>% 
       setView(lng = mean(lpoints$long), lat = mean(lpoints$lat), zoom = 09) %>% 
       addProviderTiles("Stamen.TonerLite", 
           group = "Toner", 
           options = providerTileOptions(minzoom = 1, maxzoom = 10)) %>% 
       addTiles(group = "OSM") %>% 
       addProviderTiles("Esri.WorldTopoMap",  
           group = "Topo") %>% 
       addProviderTiles("OpenStreetMap.Mapnik", group = "Mapnik") %>% 
       addProviderTiles("CartoDB.Positron",  group = "CartoDB") %>% 
       setMaxBounds(([email protected][1,1] - .3), 
          ([email protected][2,1] - .3), 
          ([email protected][1,2] + .3), 
          ([email protected][2,2] + .3)) %>% 
       addMarkers(lpoints$long, 
         lpoints$lat, 
         popup=ppopup, 
         icon = tec_icon, 
         group="Parishes", 
         clusterOptions = markerClusterOptions()) %>% 
      addLayersControl(baseGroups = c("Toner", "OSM", "Topo", "Mapnik", "CartoDB"), 
         options = layersControlOptions(collapsed = TRUE)) 

回答

3

幾個要點:

  1. 這是minZoommaxZoom(注意資金ž
  2. 你需要在每個Tile功能的選項你想設置 的縮放級別。

library(leaflet) 

## the first two tiles have a zoom level control - the others don't 
leaflet() %>% 
    setView(lng = 144, lat = -37, zoom = 09) %>% 
    addProviderTiles("Stamen.TonerLite", 
        group = "Toner", 
        options = providerTileOptions(minZoom = 8, maxZoom = 10)) %>% 
    addTiles(group = "OSM", 
      options = providerTileOptions(minZoom = 8, maxZoom = 10)) %>% 
    addProviderTiles("Esri.WorldTopoMap",  
        group = "Topo") %>% 
    addProviderTiles("OpenStreetMap.Mapnik", group = "Mapnik") %>% 
    addProviderTiles("CartoDB.Positron",  group = "CartoDB") %>% 
    addLayersControl(baseGroups = c("Toner", "OSM", "Topo", "Mapnik", "CartoDB"), 
        options = layersControlOptions(collapsed = TRUE)) 
+0

謝謝您的回答。 –