本文介绍了R:在传单地图中添加标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在整个地图上添加标题(与图例标题不同: addLegend(...,title =",...):按标题",我的意思是覆盖的地图组件在移动地图时会保留在原处(与覆盖的图像不同).

I'd like to add a title to the whole map (different from the legend title: addLegend(..., title = "", ...): by "title", I mean an overlaid map component that stays in place while the map is moved (unlike an overlaid image).

RStudio的 传单 中的一个选项是R吗?

Is that an option in RStudio's leaflet for R?

leafletR 具有 title =" 参数,但是会更新网页的标题:它不会为地图添加标题.

leafletR has a title="" argument but it updates the title of the webpage: it does not add a title to the map.

推荐答案

您应提供一个可复制的示例.但是,使用addControl您可以尝试:

You should provide a reproducible example.But using addControl you could try:

 library(leaflet)
 library(htmlwidgets)
 library(htmltools)

 rr <- tags$div(
   HTML('<a href="https://cran.r-project.org/"> <img border="0" alt="ImageTitle" src="/PathToImage/ImageR.jpeg" width="300" height="100"> </a>')
 )

 map_leaflet <- leaflet() %>%
   addTiles() %>%
   addMarkers(50, 50) %>%
   addControl(rr, position = "bottomleft")

 saveWidget(map_leaflet, file="testing.html")

打开保存在工作目录中的testing.html,您将在地图上看到一张图片(只需创建一个带有地图标题的图片)即可.它不是居中的,您只能将控件放在四个角上.希望对您有帮助!

Open testing.html saved in your working directory and you will see an image (just create an image with Map Title in it) over your map. It is not center you can only put the control on the four corners. Hope it helps!

这篇关于R:在传单地图中添加标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 04:53