我正在使用传单在R中创建一个交互式地图。我正在使用AddMapPane将标签从基础地图(CartoDB.PositronOnlyLabels)带到最前面。我的代码在RMarkdown文件中成功运行,但是当我编织到html时,基本地图标签消失了。
这是我从另一个堆栈交换中获得的一些示例代码。这段代码在RMarkdown / viewer中工作时具有相同的问题,但在您编织到html时却没有。
任何帮助将不胜感激!
map = leaflet() %>%
addMapPane(name = "polygons", zIndex = 410) %>%
addMapPane(name = "maplabels", zIndex = 420) %>% # higher zIndex rendered on top
addProviderTiles("CartoDB.PositronNoLabels") %>%
addProviderTiles("CartoDB.PositronOnlyLabels",
options = leafletOptions(pane = "maplabels"),
group = "map labels") %>%
addPolygons(data = gadmCHE, color = "black", weight = 1,
fillColor = "cornflowerblue", fillOpacity = 0.9,
group = "gadmCHE",
options = leafletOptions(pane = "polygons")) %>%
addLayersControl(baseGroups = "CartoDB.PositronNoLabels",
overlayGroups = c("map labels",
"gadmCHE"))
map
以下是我在R Markdown中看到的图像:
CORRECT visual of map with base map labels brought to the top layer
这是我编织到html时看到的内容: