<legend id='7xdsR'><style id='7xdsR'><dir id='7xdsR'><q id='7xdsR'></q></dir></style></legend>

<tfoot id='7xdsR'></tfoot>

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

        <small id='7xdsR'></small><noframes id='7xdsR'>

          <bdo id='7xdsR'></bdo><ul id='7xdsR'></ul>
      1. 传单:更新 GeoJson 过滤器?

        时间:2023-08-09

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

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

                • <bdo id='yu3gc'></bdo><ul id='yu3gc'></ul>
                • 本文介绍了传单:更新 GeoJson 过滤器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想用数据填充 GeoJson 层,然后动态过滤要显示的特征.

                  I would like to populate a GeoJson layer with data and then dynamically filter what features to show.

                  我已经让过滤器功能工作,但我不知道如何更改过滤器然后刷新图层.

                  I have gotten the filter function to work but I do not know how to change the filter and then refresh the layer.

                  添加数据后有什么方法可以更新过滤器?

                  Is there any way I can update the filter after I have added the data?

                  推荐答案

                  我通过将每个功能类型添加到不同的 LayerGroup 基于特征的属性.例如

                  I did this by adding each feature type to a different LayerGroup based on a property of the feature. e.g.

                  GeoJSON

                  var data =[
                    {
                     type: "Feature",
                     properties: {
                        type: "type1"
                     },
                     geometry: {
                        type: "Point",
                        coordinates: [-1.252,52.107]
                     }
                    },
                    {
                     type: "Feature",
                     properties: {
                        type: "type2"
                     },
                     geometry: {
                        type: "Point",
                        coordinates: [-2.252,54.107]
                     }
                    }
                  ];
                  

                  创建 GeoJSON 层

                  //array to store layers for each feature type
                  var mapLayerGroups = [];
                  
                  //draw GEOJSON - don't add the GEOJSON layer to the map here
                  L.geoJson(data, {onEachFeature: onEachFeature})//.addTo(map);
                  
                  /*
                   *for all features create a layerGroup for each feature type and add the feature to the    layerGroup
                  */
                  function onEachFeature(feature, featureLayer) {
                  
                      //does layerGroup already exist? if not create it and add to map
                      var lg = mapLayerGroups[feature.properties.type];
                  
                      if (lg === undefined) {
                          lg = new L.layerGroup();
                          //add the layer to the map
                          lg.addTo(map);
                          //store layer
                          mapLayerGroups[feature.properties.type] = lg;
                      }
                  
                      //add the feature to the layer
                      lg.addLayer(featureLayer);      
                  }
                  

                  然后您可以调用 Leaflet map.addLayer/removeLayer 函数,例如

                  Then you can call the Leaflet map.addLayer/removeLayer functions e.g.

                  //Show layerGroup with feature of "type1"
                  showLayer("type1");
                  
                  /*
                  * show/hide layerGroup   
                  */
                  function showLayer(id) {
                      var lg = mapLayerGroups[id];
                      map.addLayer(lg);   
                  }
                  function hideLayer(id) {
                      var lg = mapLayerGroups[id];
                      map.removeLayer(lg);   
                  }
                  

                  这篇关于传单:更新 GeoJson 过滤器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:LeafletJS:如何删除缩放控件 下一篇:在传单中旋转标记

                  相关文章

                  最新文章

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

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

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