2017-10-17 58 views
1

它可能覆蓋圖像到R小冊子地圖 - 或者可能在小冊子html - 將保持固定在地圖本身之上?覆蓋R小冊子上的靜態圖像htmlwidget

也就是說,圖像不會在地圖上呈現,而是固定在瀏覽器的視口中,這樣當您平移或縮放時,它將保持相同的位置。

例如,我會想覆蓋this image,固定到下面的R代碼裏面呈現的地圖的左上:

library(htmlwidgets) 
library(leaflet) 

m <- leaflet() %>% 
    addTiles() %>% 
    addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R") 

saveWidget(m, file = "m.html", selfcontained = F) 

回答

2

您可以addLogo()從包MapView的做到這一點。

library(htmlwidgets) 
library(leaflet) 
library(mapview) 

img <- "https://www.r-project.org/logo/Rlogo.svg" 

m <- leaflet() %>% 
    addTiles() %>% 
    addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R") %>% 
    addLogo(img, url = "https://www.r-project.org/logo/") 

m 
1

在HTML中,你可以用一個高Z-添加index - 將內部放置在htmlwidget上方。

對於上面的示例,包括以上html以上的htmlwidget容器覆蓋圖像。

<div style="position:fixed;top:0px;left:0px;z-index:11000;"> 
<img src="https://www.r-project.org/logo/Rlogo.svg"/> 
</div> 
0

我知道這是一個傳單的問題,但我想看看它是否與googelway和add_overlay()工作 - 和它的作用:

library(googleway) 

map_key <- 'my_map_key' 

google_map(key = map_key) %>% 
    add_overlay(north = -36.852, east = 174.768, west = 174.668, south = -36.952, 
      overlay_url = "https://www.r-project.org/logo/Rlogo.svg") 

enter image description here