如何用css设置leaftlet搜索框位置(leaflet.extra包)

时间:2018-06-10 13:15:36

标签: css r shiny leaflet

Leaftlet允许有限的控制位置,如" topleft"或" topright"。如何在Shiny中设置带有css的leaftlet搜索框位置(从leaflet.extra包中搜索)? 这是一个最小的例子:

value(Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1[EFCoreBugs.Blog]).Select(dtoBlog => new BlogDto() {Post = IIF((IIF(dtoBlog.Posts.Any(), dtoBlog.Posts.FirstOrDefault(), null) == null), null, new PostDto() {})})

如何将搜索框设置在任何位置? (例如顶部中心?)

浏览器检查为我提供了一些元素:

      library(leaflet)
      library(leaflet.extras)
      library(shiny)

      ui <- fillPage(leafletOutput("mymap"))

      server <- function(input, output, session) {
        output$mymap <- renderLeaflet({
          leaflet() %>%
            addProviderTiles(providers$Esri.WorldStreetMap) %>%
            addSearchOSM()
        })

      }

      shinyApp(ui, server)

我尝试用css:

 <a class="search-button" href="#" title="Search using Google Geocoder"     style="outline: none;"></a>

1 个答案:

答案 0 :(得分:1)

您可以使用leaflet-control-search选择器。需要!important,以便您可以覆盖默认保证金。

tags$head(tags$style(
  HTML('.leaflet-control-search {
    margin-top: 100px !important;
  }')
))

demo