R Leaflet在上面留下标记

时间:2017-09-07 23:22:06

标签: r shiny maps leaflet

您好我正在尝试在Leaflet R中为地图创建多个图层,同时将标记保留为最顶层。我尝试在highlightOptions()中使用bringToFront()作为addCircleMarkers选项,但每当我使用addLayersControl()更改图层时,它们都会移动到最底层。

建议?

renderLeaflet(

leaflet()%>%
  addTiles()%>%
  addPolygons(data = district_shapes, 
              weight = 1,
              fillColor = "blue",
              fillOpacity = .25,
              label = labels,
              group = "School District"
              ) %>%
  addPolygons(data = district_shapes, 
              weight = 1,
              fillColor =~frl_pal(district_shapes$FRL),
              fillOpacity = .7,
              label = labels,
              popup = frl_label,
              group = "Free and Reduced Lunch"
              ) %>%
  addPolygons(data = district_shapes, 
              weight = 1,
              fillColor =~avgIncome_pal(district_shapes$Avg_Household_Income),
              fillOpacity = .7,
              label = labels,
              group = "Average Household Income"
              ) %>%
  addLayersControl(
    baseGroup = c("School District","Free and Reduced Lunch", "Average Household Income"),
    options = layersControlOptions(collapsed = TRUE)
  )%>%
  addCircleMarkers(
    lng = ~Longitude ,
    lat = ~Latitude,
    data = charter_year_filter(),
    label = ~Account_Name,
    color = ~Color,
    popup = sprintf("<strong><u>%s</u></strong><br/>%s <br/>%s <br/>%s <br/>%s",
                  charter_geo$Account_Name, 
                  charter_geo$Site1, 
                  charter_geo$Site2,
                  charter_geo$Site3, 
                  charter_geo$Site4)%>% lapply(htmltools::HTML),
    stroke = T,
    options = highlightOptions(bringToFront = T),
    opacity = 1,
    fillOpacity = .5,
    fill = T,
    clusterOptions = markerClusterOptions()
  )
)

0 个答案:

没有答案