【问题标题】:Custom markers in leaflet传单中的自定义标记
【发布时间】:2015-07-21 13:51:47
【问题描述】:

有没有办法在 R 中为传单获取自定义标记图标?我尝试使用教程中提供的示例代码,但是 makeIcon 函数似乎不存在。我试过的代码在这里,但是没有用。

http://rstudio.github.io/leaflet/markers.html

任何建议将不胜感激。总体目标是将其实现到闪亮的 Web 应用程序中。

非常感谢

【问题讨论】:

    标签: r shiny leaflet


    【解决方案1】:

    makeIcon 函数确实存在,至少在我的传单包中是这样。 以下代码(来自tutorial)对我来说很好..

    greenLeafIcon <- makeIcon(
      iconUrl = "http://leafletjs.com/examples/custom-icons/leaf-green.png",
      iconWidth = 38, iconHeight = 95,
      iconAnchorX = 22, iconAnchorY = 94,
      shadowUrl = "http://leafletjs.com/examples/custom-icons/leaf-shadow.png",
      shadowWidth = 50, shadowHeight = 64,
      shadowAnchorX = 4, shadowAnchorY = 62
    )
    
    leaflet(data = quakes[1:20,]) %>% addTiles() %>%
      addMarkers(~long, ~lat, ~as.character(mag), icon = greenLeafIcon)
    

    【讨论】:

      猜你喜欢
      • 2016-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多