• <bdo id='5rIfL'></bdo><ul id='5rIfL'></ul>
    1. <i id='5rIfL'><tr id='5rIfL'><dt id='5rIfL'><q id='5rIfL'><span id='5rIfL'><b id='5rIfL'><form id='5rIfL'><ins id='5rIfL'></ins><ul id='5rIfL'></ul><sub id='5rIfL'></sub></form><legend id='5rIfL'></legend><bdo id='5rIfL'><pre id='5rIfL'><center id='5rIfL'></center></pre></bdo></b><th id='5rIfL'></th></span></q></dt></tr></i><div id='5rIfL'><tfoot id='5rIfL'></tfoot><dl id='5rIfL'><fieldset id='5rIfL'></fieldset></dl></div>
      <tfoot id='5rIfL'></tfoot>
      <legend id='5rIfL'><style id='5rIfL'><dir id='5rIfL'><q id='5rIfL'></q></dir></style></legend>

      <small id='5rIfL'></small><noframes id='5rIfL'>

    2. R 的传单:如何更改默认 CSS 集群类

      时间:2023-05-28
          <tfoot id='C1ORx'></tfoot>

          <legend id='C1ORx'><style id='C1ORx'><dir id='C1ORx'><q id='C1ORx'></q></dir></style></legend>
            <tbody id='C1ORx'></tbody>
              <i id='C1ORx'><tr id='C1ORx'><dt id='C1ORx'><q id='C1ORx'><span id='C1ORx'><b id='C1ORx'><form id='C1ORx'><ins id='C1ORx'></ins><ul id='C1ORx'></ul><sub id='C1ORx'></sub></form><legend id='C1ORx'></legend><bdo id='C1ORx'><pre id='C1ORx'><center id='C1ORx'></center></pre></bdo></b><th id='C1ORx'></th></span></q></dt></tr></i><div id='C1ORx'><tfoot id='C1ORx'></tfoot><dl id='C1ORx'><fieldset id='C1ORx'></fieldset></dl></div>

              <small id='C1ORx'></small><noframes id='C1ORx'>

                <bdo id='C1ORx'></bdo><ul id='C1ORx'></ul>
                本文介绍了R 的传单:如何更改默认 CSS 集群类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                如何从 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.

                .marker-cluster-small {
                    background-color: rgba(181, 226, 140, 1.0);
                    }
                .marker-cluster-small div {
                    background-color: rgba(110, 204, 57, 1.0);
                    }
                

                有没有办法在 iconCreateFunction 中做到这一点?

                Is there a way to do this from within iconCreateFunction ?

                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) });
                
                  }"))
                )
                

                推荐答案

                您可以尝试将内联 CSS 添加到创建图标的函数中的不同标记,例如:

                You can maybe try to add inline CSS to the different markers in the function that creates the icons, for ex:

                clusterOptions = markerClusterOptions(iconCreateFunction=JS("function (cluster) {    
                    var childCount = cluster.getChildCount();  
                    if (childCount < 100) {  
                      c = 'rgba(181, 226, 140, 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', iconSize: new L.Point(40, 40) });
                
                  }")
                

                如果你使用 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:

                ui <- fluidPage(
                  tags$head(tags$style(HTML("
                  .marker-custom-small {
                  background-color: rgba(181, 226, 140, 1);
                    }
                .marker-customr-small div {
                    background-color: rgba(110, 204, 57, 1);
                    }
                
                .marker-custom-medium {
                    background-color: rgba(241, 211, 87, 1);
                    }
                .marker-custom-medium div {
                    background-color: rgba(240, 194, 12, 1);
                    }
                
                .marker-custom-large {
                    background-color: rgba(253, 156, 115, 1);
                    }
                .marker-custom-large div {
                    background-color: rgba(241, 128, 23, 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>', className: 'marker-cluster' + c, iconSize: new L.Point(40, 40) });
                
                  }"))
                    )
                  })
                }
                
                shinyApp(ui,server)
                

                无法弄清楚如何在 shiny 应用程序之外的 leaflet 中使用自定义 CSS.

                Couldn't figure out how to have custom CSS in the leaflet outside of a shiny app.

                这篇关于R 的传单:如何更改默认 CSS 集群类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:函数事件(onChange)中的调用函数,来自在 Leaflet 和 下一篇:如何使用传单 map.on('click', function) 事件处理

                相关文章

                最新文章

                <tfoot id='z3AyD'></tfoot>

                  <bdo id='z3AyD'></bdo><ul id='z3AyD'></ul>

                <small id='z3AyD'></small><noframes id='z3AyD'>

                  <i id='z3AyD'><tr id='z3AyD'><dt id='z3AyD'><q id='z3AyD'><span id='z3AyD'><b id='z3AyD'><form id='z3AyD'><ins id='z3AyD'></ins><ul id='z3AyD'></ul><sub id='z3AyD'></sub></form><legend id='z3AyD'></legend><bdo id='z3AyD'><pre id='z3AyD'><center id='z3AyD'></center></pre></bdo></b><th id='z3AyD'></th></span></q></dt></tr></i><div id='z3AyD'><tfoot id='z3AyD'></tfoot><dl id='z3AyD'><fieldset id='z3AyD'></fieldset></dl></div>
                  1. <legend id='z3AyD'><style id='z3AyD'><dir id='z3AyD'><q id='z3AyD'></q></dir></style></legend>