Leaflet for R: How to change default CSS cluster classes(R 的传单:如何更改默认 CSS 集群类)
问题描述
如何从 Leaflet for R 界面更改定义集群对象的默认 CSS 类?例如,如果我想从 .marker-cluster-small 类中移除不透明度,我如何在 R 中做到这一点?
How do I change the default CSS classes which define cluster objects from within the Leaflet for R interface? For example, if I wanted to remove the opacity from the .marker-cluster-small class, how could I do this from within R?
这里是创建集群类的 CSS:https://github.com/Leaflet/Leaflet.markercluster/blob/64a2d5711521e56cac8ab863fb658beda5690600/dist/leaflet.markercluster-src.js
Here is the CSS which creates the cluster classes: https://github.com/Leaflet/Leaflet.markercluster/blob/64a2d5711521e56cac8ab863fb658beda5690600/dist/leaflet.markercluster-src.js
例如,我想从集群中移除不透明度,例如
For example, I want to remove the opacity from the clusters, e.g.
有没有办法在 iconCreateFunction 中做到这一点?
Is there a way to do this from within iconCreateFunction ?
推荐答案
您可以尝试将内联 CSS 添加到创建图标的函数中的不同标记,例如:
You can maybe try to add inline CSS to the different markers in the function that creates the icons, for ex:
如果你使用 shiny
,你也可以改变 iconCreateFunction
为每个标记分配不同的类,并添加 tags$style
在标题中设置这些类的 CSS.这是一个例子:
If you are using shiny
, you can also change the iconCreateFunction
to assign a different class to each marker, and add tags$style
in the header to set the CSS for these classes. Here's an example:
无法弄清楚如何在 shiny
应用程序之外的 leaflet
中使用自定义 CSS.
Couldn't figure out how to have custom CSS in the leaflet
outside of a shiny
app.
这篇关于R 的传单:如何更改默认 CSS 集群类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!