问题添加图标和图例与传单

发布于 2025-01-13 23:24:41 字数 918 浏览 3 评论 0原文

我尝试在 r markdown 中重复以下代码,但会遇到: “ htmltools::tags$polygon(id = “diamond”,points = draw_diamond(width = width,:尝试应用非功能) 中出现错误”。 如何解决这个问题?

代码来自这里: https:// /roh.engineering/posts/2021/05/map-symbols-and-size-legends-for-leaflet/

library(leaflet)
library(leaflegend)
data("quakes")
symbols <- makeSizeIcons(
  values = quakes$depth,
  shape = 'diamond',
  color = 'red',
  fillColor = 'red',
  opacity = .5,
  baseSize = 10
)

leaflet() %>%
  addTiles() %>%
  addMarkers(data = quakes,
             icon = symbols,
             lat = ~lat, lng = ~long) %>%
  addLegendSize(
    values = quakes$depth,
    color = 'red',
    fillColor = 'red',
    opacity = .5,
    title = 'Depth',
    shape = 'diamond',
    orientation = 'horizontal',
    breaks = 5)

I try to reduplicate the below code in r markdown, but meet:
"Error in htmltools::tags$polygon(id = "diamond", points = draw_diamond(width = width, : attempt to apply non-function".
how to solve this problem?

and code is from here: https://roh.engineering/posts/2021/05/map-symbols-and-size-legends-for-leaflet/

library(leaflet)
library(leaflegend)
data("quakes")
symbols <- makeSizeIcons(
  values = quakes$depth,
  shape = 'diamond',
  color = 'red',
  fillColor = 'red',
  opacity = .5,
  baseSize = 10
)

leaflet() %>%
  addTiles() %>%
  addMarkers(data = quakes,
             icon = symbols,
             lat = ~lat, lng = ~long) %>%
  addLegendSize(
    values = quakes$depth,
    color = 'red',
    fillColor = 'red',
    opacity = .5,
    title = 'Depth',
    shape = 'diamond',
    orientation = 'horizontal',
    breaks = 5)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文