我有一个工作传单地图,显示了使用clusterOptions聚类的几个标记。 我想添加地形数据和一些边框shapefile作为背景而不是默认图块。 但是,如果在同一地图上使用addRasterImage(或addPolygons),则不会渲染带有clusterOptions的addMarkers。
除了addTiles之外,还使用addRasterImage,而不是用addRasterImage替换addTiles,可以正确渲染标记簇。但是,这不是解决方案,因为出于美观和资源的原因,我不想使用图块。
library(leaflet)
# this works
leaflet(quakes) %>%
setView( lat=-23, lng=180, zoom=6) %>%
addTiles() %>%
addMarkers(~long, ~lat)
# this doesn't work, only shows polygons... if anything
leaflet(quakes) %>%
setView( lat=-23, lng=180, zoom=6) %>%
addMarkers(~long, ~lat, clusterOptions = TRUE) %>%
addPolygons(lng = ~long, lat = ~lat, fill = F, weight = 1.5, color = "gray", opacity = 0.9, fillOpacity = 0)
# this works (takes a while), but I don't want to use tiles :(
leaflet(quakes) %>%
setView( lat=-23, lng=180, zoom=6) %>%
addTiles() %>%
addMarkers(~long, ~lat, clusterOptions = TRUE) %>%
addPolygons(lng = ~long, lat = ~lat, fill = F, weight = 1.5, color = "gray", opacity = 0.9, fillOpacity = 0)
答案 0 :(得分:0)