我有以下闪亮的应用:https://ahmadmobin.shinyapps.io/Understanding_STOP/
位于"位置"标签我有一张传单地图。我想将搜索栏移到左侧。如果可能的话,我也希望有 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 :(得分:1)
你可以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
您可以使用3种不同的方式更改其位置(基于上面的链接)。我首选的方法如下,特别是如果您正在考虑进行更多自定义更改。
在闪亮的应用目录中,创建一个名为www
的子目录,
在移动搜索栏位置的文本文件中创建样式规则,您可以确定所需的确切位置,但您可以使用类似的东西(此示例只是改变margin-left
属性来移动元素在左边。
#mymap > div.leaflet-control-container > div.leaflet-top.leaflet-right > div.leaflet-control-search.leaflet-control{margin-left: 10px important;}
将文件保存为style.css
子目录中的www
在您所在的ui.R
内添加标记,包括您的地图的渲染部分:
tags$head(tags$link(rel = "stylesheet", type = "text/css", href = "style.css"))