考虑来自传单 R 包的 breweries91 数据。我在 breweries91 数据框中模拟了一个附加变量,该变量对应于啤酒厂的两组。
下面的代码将重现下图的左侧部分:
这里在 Javascript 中有一个解决方案:
http://bl.ocks.org/gisminister/10001728
另一个例子在这里:https : //github.com/SINTEF-9012/PruneCluster
饼图的主题也在那里讨论:https : //ux.stackexchange.com/questions/76402/how-to-cluster-map-markers-with-different-statuses
有没有人通过 JS 函数在传单选项中使用过类似的 JS 代码?
library(leaflet)
library(dplyr)
data("breweries91",package="leaflet")
set.seed(1);breweries91$goodbear<-sample(as.factor(c("terrific","marvelous")),nrow(breweries91),replace=T)
leaflet() %>%
addTiles() %>%
addMarkers(data=breweries91,
clusterOptions = markerClusterOptions(
iconCreateFunction =
JS("function(cluster) {
return new L.DivIcon({
html: '<div style=\"background-color:rgba(77,77,77,0.5)\"><span>' + cluster.getChildCount() + '</div><span>',
className: 'marker-cluster'
});}")))
Run Code Online (Sandbox Code Playgroud)
如何调整代码以生成右侧的图像?