2017-08-25 96 views
0

我有以下閃亮的應用:https://ahmadmobin.shinyapps.io/Understanding_STOP/[R單張搜索功能

的「位置」選項卡下,我有一個單張地圖。我想將搜索欄移到左側。如果可能的話,我想也想addResetMapButton()但它是沒有必要的。

這裏是我的R代碼裏面:

output$mymap <- renderLeaflet({ 
leaflet(Locations) %>% 
addTiles() %>% 
addCircleMarkers(color = Locations$color,clusterOptions= markerClusterOptions, 
       label=~Official_Name_of_Agency, popup=~geoAddress, group='Locations') %>% 
addLegend(labels = c("AA", "CHC", "FHT", "NPLC"), colors = c("black", "purple", "blue", "yellow")) %>% 
addProviderTiles(providers$Stamen.TonerLite, 
    options = providerTileOptions(noWrap = TRUE)) %>% 
addSearchOSM(options = searchOSMOptions()) 

回答

0

可以style your apps with CSS to make custom changes to your app

對於搜索欄,你正在尋找的選擇是:

#mymap > div.leaflet-control-container > div.leaflet-top.leaflet-right > div.leaflet-control-search.leaflet-control 

您可以使用三種不同的方式改變其立場(根據上面的鏈接)。我的首選方式如下,特別是如果您正在考慮進行更多自定義更改。

  • 在你閃亮的應用程序目錄下創建一個名爲www子目錄,

    創建在移動搜索欄的位置的文本文件的樣式規則,你可以計算你想要的確切位置,但你可以使用這樣的(本實施例中只是改變了margin-left屬性的元素移動到左側。

    #mymap > div.leaflet-control-container > div.leaflet-top.leaflet-right > div.leaflet-control-search.leaflet-control{margin-left: 10px important;} 
    

    文件保存爲style.csswww的子目錄內,

    添加標籤,就可以ui.R內隨時隨地可以包括地圖具有呈現部分:

    tags$head(tags$link(rel = "stylesheet", type = "text/css", href = "style.css"))

+0

嗨eclark,感謝找回。請參閱下面的回覆。週末愉快! –

+0

它似乎並沒有工作: style.css file #mymap> div.leaflet-control-container> div.leaflet-top.leaflet-right> div.leaflet-control-search.leaflet-control {margin -left:10px important;} UI: tabItem(tabName =「fourth」, tags $ head(tags = $ link(rel =「stylesheet」,type =「text/css」,href =「style.css 「)), leafletOutput(」mymap「,height = 700) ), –