2016-06-21 126 views
0

我在我閃亮的應用中渲染了一些傳單地圖,問題在於傳說中的地圖顯示不正確,圖例項目非常奇怪(圖2) 。我在R studio和Rstudio Viewer中創建了相同的地圖,圖例項目對齊方式正確(圖像1)。
我已經嘗試在我閃亮的代碼中使用CSS標籤來自定義圖例,但沒有任何工作。傳單中的傳說物品沒有正確顯示(對齊)

This it how the legend looks in viewer when I create the leaflet map in rstudio

This is how it looks in browser via shiny app

下面是示例代碼顯示如何我呈現單張情節(以及CSS標籤的例子,我已經試過)。我不知道爲什麼這些項目是這樣顯示的。我真的很感謝你的幫助。

... 
tabPanel("plot", 
    tagList(
    tags$head(
     tags$style(
     ".leaflet .legend {width:200px; text-align: left;}", 
     ".leaflet .legend i{float: left;}", 
     ".leaflet .legend label{float:left; text-align: left;}" 
     ) 
    ) 
), 

    leafletOutput("leaflet_plot", width = 800, height = 550) 
) 
... 

# code to create leaflet 
output$leaflet_plot <- renderLeaflet({ 
    pal <- c("#F1F1F1", brewer.pal(5, "YlOrBr")) 
    opts <- providerTileOptions(opacity = 0) 
    map <- leaflet(shape_file) %>% addProviderTiles("CartoDB.PositronNoLabels", options = opts) 
    map <- map %>% addPolygons(fillColor = ~colorFactor(pal, shape_file$var)(var) 
    map <- map %>% addLegend("bottomleft", title = "Employment/Acre", pal = colorFactor(pal, NULL), values = ~var) 
    map 
}) 

感謝,
阿希什

+2

請發佈一個可重複的例子。 –

+0

同樣的問題,添加到我的CSS作爲亞當引用如下: div.info.legend.leaflet-控制br { 明確:都; } –

回答

0

如果瀏覽器的縮放級別超過100%,這可能發生。 看看這個duplicate post有一個可重複的例子。