传单R:选择&;快速移动

传单R:选择&;快速移动,r,leaflet,shiny,R,Leaflet,Shiny,我正在开发一种工具,它有光泽和传单: 我希望当客户单击VAR时(参见UI代码示例NE),地图会转到另一个视图,例如纯传单中的示例: L.easyButton( '<strong>NE</strong>', function(){ //zoomTo.setView([55, -2], 4); map.setView([46.95, 6.85], 12); }).addTo(map); 要更新传单地图,您应该使用传单代理,您可以阅读相关内容 这样做的目的是,

我正在开发一种工具,它有光泽和传单: 我希望当客户单击VAR时(参见UI代码示例NE),地图会转到另一个视图,例如纯传单中的示例:

  L.easyButton( '<strong>NE</strong>', function(){
  //zoomTo.setView([55, -2], 4);
  map.setView([46.95, 6.85], 12);
  }).addTo(map);

要更新传单地图,您应该使用
传单代理
,您可以阅读相关内容

这样做的目的是,您需要有一个
reactive
值,该值在更改选择时更新,
reactive
值由
proxy
及其用于执行更新的值观察

应该是这样的:

output$map <- renderLeaflet({
        leaflet(data) %>%
            addTiles(urlTemplate = "//{s}.tiles.mapbox.com/v3/jcheng.map-5ebohr46/{z}/{x}/{y}.png",
                     attribution = 'Maps by <a href="http://www.mapbox.com/">Mapbox</a>'
            ) %>% 
            setView(lng = 6.6328200, lat = 46.5160000, zoom = 12) %>% 
            addMarkers(data$long, data$lat, label = data$nom)            
    })

    center <- reactive({
        subset(data, nom == input$canton) 
        # or whatever operation is needed to transform the selection 
        # to an object that contains lat and long
    })

    observe({
        leafletProxy('map') %>% 
            setView(lng =  center()$long, lat = center()$lat, zoom = 12)
    })
输出$map%
addTiles(urlTemplate=“//{s}.tiles.mapbox.com/v3/jcheng.map-5ebohr46/{z}/{x}/{y}.png”,
属性='Maps by'
) %>% 
setView(lng=6.6328200,纬度=46.5160000,缩放=12)%>%
添加标记(数据$long,数据$lat,标签=数据$nom)
})
中心%
设置视图(lng=center()$long,lat=center()$lat,zoom=12)
})

要更新传单地图,您应该使用传单代理,您可以阅读相关内容

这样做的目的是,您需要有一个
reactive
值,该值在更改选择时更新,
reactive
值由
proxy
及其用于执行更新的值观察

应该是这样的:

output$map <- renderLeaflet({
        leaflet(data) %>%
            addTiles(urlTemplate = "//{s}.tiles.mapbox.com/v3/jcheng.map-5ebohr46/{z}/{x}/{y}.png",
                     attribution = 'Maps by <a href="http://www.mapbox.com/">Mapbox</a>'
            ) %>% 
            setView(lng = 6.6328200, lat = 46.5160000, zoom = 12) %>% 
            addMarkers(data$long, data$lat, label = data$nom)            
    })

    center <- reactive({
        subset(data, nom == input$canton) 
        # or whatever operation is needed to transform the selection 
        # to an object that contains lat and long
    })

    observe({
        leafletProxy('map') %>% 
            setView(lng =  center()$long, lat = center()$lat, zoom = 12)
    })
输出$map%
addTiles(urlTemplate=“//{s}.tiles.mapbox.com/v3/jcheng.map-5ebohr46/{z}/{x}/{y}.png”,
属性='Maps by'
) %>% 
setView(lng=6.6328200,纬度=46.5160000,缩放=12)%>%
添加标记(数据$long,数据$lat,标签=数据$nom)
})
中心%
设置视图(lng=center()$long,lat=center()$lat,zoom=12)
})

由于现在这是不可复制的,我们应该至少有一段摘录自
数据
,可能还有
gomap.js
中的代码。由于现在这是不可复制的,我们应该至少有一段摘录自
数据
以及
gomap.js
中的代码。我的数据集包括纬度和经度,还有一些变量,如Canton和Sow,没有一些示例数据,我只能这样做,我更新了我的示例,我希望它对你更有意义,谢谢你的帮助和时间;)我的数据集包括纬度和经度,以及一些变量,如Canton和Sow,没有一些示例数据,我只能这样做。我更新了我的示例,希望它对你更有意义。谢谢你的帮助和时间;)
 #data
 1           Genève     GE 022 329 11 69                                                          www.fegpa.ch  6.164722 46.19853
 2 Chavannes-près-Renens     VD 021 633 44 32                                                        croix-bleue.ch  6.575761 46.53280
 3              Lausanne     VD 021 623 84 84                                                            www.fva.ch  6.611342 46.52284
 4             Neuchâtel     NE 032 889 62 10                                                  http://www.cenea.ch/  6.909872 46.98825
 5              Delémont     JU 032 421 80 80 http://www.addiction-jura.ch  6.411595 46.94195
 6              Lausanne     VD 021 321 29 11                                                www.addictionsuisse.ch  6.626040 46.51873
output$map <- renderLeaflet({
        leaflet(data) %>%
            addTiles(urlTemplate = "//{s}.tiles.mapbox.com/v3/jcheng.map-5ebohr46/{z}/{x}/{y}.png",
                     attribution = 'Maps by <a href="http://www.mapbox.com/">Mapbox</a>'
            ) %>% 
            setView(lng = 6.6328200, lat = 46.5160000, zoom = 12) %>% 
            addMarkers(data$long, data$lat, label = data$nom)            
    })

    center <- reactive({
        subset(data, nom == input$canton) 
        # or whatever operation is needed to transform the selection 
        # to an object that contains lat and long
    })

    observe({
        leafletProxy('map') %>% 
            setView(lng =  center()$long, lat = center()$lat, zoom = 12)
    })