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

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

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

      1. <tfoot id='Qxn97'></tfoot>
        <legend id='Qxn97'><style id='Qxn97'><dir id='Qxn97'><q id='Qxn97'></q></dir></style></legend>

        传单R,如何使与儿童统计相关的聚集图标出现

        时间:2023-08-08
          1. <tfoot id='NfPEK'></tfoot>
              <tbody id='NfPEK'></tbody>

            • <bdo id='NfPEK'></bdo><ul id='NfPEK'></ul>

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

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

                  本文介绍了传单R,如何使与儿童统计相关的聚集图标出现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想根据子标记的属性总和在 Leaflet/Shiny 应用程序中自定义聚集标记的外观.

                  I'd like to customize appearance of clustered markers in Leaflet/Shiny application based on sum of an attribute of child markers.

                  类似于这个问题,它根据孩子的数量制作集群的图标颜色.如果我想根据地震震级和自定义图标怎么办?

                  It is similar to this problem, which makes icon color of clusters based on count of children. What if I want to customize icon based on the sum of magnitude of earthquakes?

                  使用纯 javascript 应用程序,似乎我应该能够将自定义属性设置为单个标记,然后从 iconCreateFunction 访问它,就像在 这个例子.

                  With pure javascript application, seems like I should be able to set custom property to individual marker, then access it from iconCreateFunction, as done in this example.

                  但是我正在为 R 的传单添加带有 addCircleMarkersaddMarkers 的标记,并且似乎我不能为正在生成的标记添加任意属性.下面的代码有效,但如果我取消注释两行(mag = ~magsum += markers[i].mag;)

                  But I am adding marker with addCircleMarkers and addMarkers from leaflet for R, and doesn't seem i can add arbitrary attribute to markers being generated. Code below works but it doesn't if i uncomment two lines (mag = ~mag and sum += markers[i].mag;)

                  leaflet(quakes) %>% addTiles() %>% addMarkers(
                    # mag = ~mag,
                    clusterOptions = markerClusterOptions(
                    iconCreateFunction=JS("function (cluster) {    
                      var markers = cluster.getAllChildMarkers();
                      var sum = 0; 
                      for (i = 0; i < markers.length; i++) {
                      //  sum += markers[i].mag;
                        sum += 1;
                      }
                      return new L.DivIcon({ html: '<div><span>' + sum + '</span></div>'});
                  
                    }")
                  
                    )
                  )
                  

                  我想过使用 addMarkerslabel= 选项,然后从 Javascript 中解析它.但是在 JS 的标记簇上使用 getAllChildMarkers() 访问的标记似乎没有 label 属性.

                  I thought about using label= option of addMarkers, and then parse it from Javascript. But the markers accessed with getAllChildMarkers() on marker cluster in JS does not seem to have label property.

                  我还考虑过将数据帧从 R 传递到传单(JS),不知何故,也许 喜欢这个例子,或 this ...?

                  I also thought about passing a dataframe from R to leaflet(JS), somehow, maybe like this example, or this ...?

                  推荐答案

                  找到了我的答案.似乎我可以在 addMarkeroptions= 中放置任意属性:

                  Found my answer. Seems like I can put arbitrary property inside options= in addMarker:

                  leaflet(quakes) %>% addTiles() %>% addMarkers(
                    options = markerOptions(mag = ~mag),
                    clusterOptions = markerClusterOptions(
                    iconCreateFunction=JS("function (cluster) {    
                      var markers = cluster.getAllChildMarkers();
                      var sum = 0; 
                      for (i = 0; i < markers.length; i++) {
                        sum += Number(markers[i].options.mag);
                  //      sum += 1;
                      }
                      return new L.DivIcon({ html: '<div><span>' + sum + '</span></div>'});
                    }")
                    )
                  )
                  

                  这篇关于传单R,如何使与儿童统计相关的聚集图标出现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:使用 EPSG:25832 投影在 Leaflet 中垂直对齐 TMS 瓷砖 下一篇:何时使用 L.TileLayer 与 L.tileLayer

                  相关文章

                  最新文章

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

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

                      <tfoot id='SRcMs'></tfoot>