showGroup无法在R中使用Leaflet正常工作

时间:2018-07-30 15:50:24

标签: r leaflet r-leaflet

我有以下代码:

# Get unique list of groups needed
lsl <- unique(origAddress$LIHN_Line)

# create initial leaflet
mt <- leaflet() %>%
  setView(lng = sv_lng, lat = sv_lat, zoom = sv_zoom) %>%
  addTiles(group = "OSM (default)") %>%
  addProviderTiles(providers$Stamen.Toner, group = "Toner") %>%
  addProviderTiles(providers$Stamen.TonerLite, group = "Toner Lite")

# for loop to cycle through adding layers
for(i in 1:length(lsl)){
  #l <- lsl[i]
  mt <- mt %>%
    addCircles(
      data = subset(origAddress, origAddress$LIHN_Line == lsl[i])
      , group = lsl[i]
      , radius = 3
      , fillOpacity = 0.6
    )
}

# add layercontrol
mt <- mt %>%
  addLayersControl(
    baseGroups = c("OSM (default)", "Toner", "Toner Lite"),
    overlayGroups = lsl,
    options = layersControlOptions(collapsed = TRUE
      , position = "bottomright")
  ) %>%
  showGroup("Medical")

# print map
mt

问题是showGroup()函数无法正常运行。我检查了地图的元素,并得到以下信息:

<span> Medical</span>

所以我不明白为什么只不显示该组。

0 个答案:

没有答案