大佬教程收集整理的这篇文章主要介绍了R的Leaflet:如何更改默认的CSS群集类,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这是创建集群类的CSS:https://github.com/Leaflet/Leaflet.markercluster/blob/64a2d5711521e56cac8ab863fb658beda5690600/dist/leaflet.markercluster-src.js@H_607_3@
例如,我想从群集中删除不透明度,例如@H_607_3@
.marker-cluster-small { BACkground-color: rgba(181,226,140,1.0); } .marker-cluster-small div { BACkground-color: rgba(110,204,57,1.0); }
有没有办法在iconCreateFunction中执行此操作?@H_607_3@
library(leaflet) leaflet(quakes) %>% addTiles() %>% addMarkers( clusterOptions = markerClusterOptions(iconCreateFunction=JS("function (cluster) { var childCount = cluster.getChildCount(); var c = ' marker-cluster-'; if (childCount < 100) { c += 'large'; } else if (childCount < 1000) { c += 'medium'; } else { c += 'small'; } return new l.DivIcon({ html: '<div><span>' + childCount + '</span></div>',className: 'marker-cluster' + c,iconSize: new l.Point(40,40) }); }")) )
clusterOptions = markerClusterOptions(iconCreateFunction=JS("function (cluster) { var childCount = cluster.getChildCount(); if (childCount < 100) { c = 'rgba(181,1.0);' } else if (childCount < 1000) { c = 'rgba(240,194,12,1);' } else { c = 'rgba(241,128,23,1);' } return new l.DivIcon({ html: '<div style=\"BACkground-color:'+c+'\"><span>' + childCount + '</span></div>',className: 'marker-cluster',40) }); }")
如果使用闪亮,还可以更改iconCreateFunction以为每个标记指定不同的类,并在标题中添加标签$style以设置这些类的CSs.这是一个例子:@H_607_3@
ui <- fluidPage( tags$head(tags$style(HTML(" .marker-custom-small { BACkground-color: rgba(181,1); } .marker-customr-small div { BACkground-color: rgba(110,1); } .marker-custom-medium { BACkground-color: rgba(241,211,87,1); } .marker-custom-medium div { BACkground-color: rgba(240,1); } .marker-custom-large { BACkground-color: rgba(253,156,115,1); } .marker-custom-large div { BACkground-color: rgba(241,1); }"))),leafletOutput("mymap")) server<-function(input,output,session) { output$mymap <- renderLeaflet({ leaflet(quakes) %>% addTiles() %>% addMarkers( clusterOptions = markerClusterOptions(iconCreateFunction=JS("function (cluster) { var childCount = cluster.getChildCount(); var c = ' marker-custom-'; if (childCount < 100) { c += 'large'; } else if (childCount < 1000) { c += 'medium'; } else { c += 'small'; } return new l.DivIcon({ html: '<div><span>' + childCount + '</span></div>',40) }); }")) ) }) } shinyApp(ui,server)
以上是大佬教程为你收集整理的R的Leaflet:如何更改默认的CSS群集类全部内容,希望文章能够帮你解决R的Leaflet:如何更改默认的CSS群集类所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。