<legend id='7wAPw'><style id='7wAPw'><dir id='7wAPw'><q id='7wAPw'></q></dir></style></legend>
    • <bdo id='7wAPw'></bdo><ul id='7wAPw'></ul>

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

        <tfoot id='7wAPw'></tfoot>
        <i id='7wAPw'><tr id='7wAPw'><dt id='7wAPw'><q id='7wAPw'><span id='7wAPw'><b id='7wAPw'><form id='7wAPw'><ins id='7wAPw'></ins><ul id='7wAPw'></ul><sub id='7wAPw'></sub></form><legend id='7wAPw'></legend><bdo id='7wAPw'><pre id='7wAPw'><center id='7wAPw'></center></pre></bdo></b><th id='7wAPw'></th></span></q></dt></tr></i><div id='7wAPw'><tfoot id='7wAPw'></tfoot><dl id='7wAPw'><fieldset id='7wAPw'></fieldset></dl></div>
      1. 将现有的传单多边形添加到现有的传单图层

        时间:2023-08-09

        <tfoot id='ZqQhT'></tfoot>
          <tbody id='ZqQhT'></tbody>

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

              <i id='ZqQhT'><tr id='ZqQhT'><dt id='ZqQhT'><q id='ZqQhT'><span id='ZqQhT'><b id='ZqQhT'><form id='ZqQhT'><ins id='ZqQhT'></ins><ul id='ZqQhT'></ul><sub id='ZqQhT'></sub></form><legend id='ZqQhT'></legend><bdo id='ZqQhT'><pre id='ZqQhT'><center id='ZqQhT'></center></pre></bdo></b><th id='ZqQhT'></th></span></q></dt></tr></i><div id='ZqQhT'><tfoot id='ZqQhT'></tfoot><dl id='ZqQhT'><fieldset id='ZqQhT'></fieldset></dl></div>
                <bdo id='ZqQhT'></bdo><ul id='ZqQhT'></ul>
                <legend id='ZqQhT'><style id='ZqQhT'><dir id='ZqQhT'><q id='ZqQhT'></q></dir></style></legend>
                  本文介绍了将现有的传单多边形添加到现有的传单图层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有一堆存储在数据库中的多边形.我想将它们添加到地图中,以便可以使用 leaflet-draw 工具栏.虽然,现在多边形已添加到地图中,但我无法对其进行编辑.

                  I have a bunch of polygons which are stored in a database. I would like to add them to the map in such a way that they can be edited using the leaflet-draw toolbar. Although, now the polygons get added to the map, I am unable edit them.

                  我认为这是因为它们没有添加到 layerGroup() 添加新绘制的形状.

                  I think this is because they are not added to the layerGroup() to which newly drawn shapes are added.

                  请帮忙.

                  推荐答案

                  你必须将你的多边形添加到 featureGroup drawnItems !比方说,

                  You have to add your polygons to the featureGroup drawnItems ! Let's say,

                      var polyLayers = dbArray;
                  

                  是您的带有多边形的数据库数组.首先使用您绘制的项目创建一个特征组:

                  is your database array with polygons. First create a feature group with your drawn items:

                      var drawnItems = new L.FeatureGroup();
                  

                  并将其添加到地图中:

                      map.addLayer(drawnItems);
                  

                  然后你只需要从你的数据库中迭代你的多边形并将它们添加到drawedItems FeatureGroup:

                  Then you simply need to iterate over your polygons from your database and add them to the drawnItems FeatureGroup:

                      for(layer of polyLayers) {
                          drawnItems.addLayer(layer); 
                      };
                  

                  现在图层已添加到地图并可以编辑.

                  Now the layers are added to the map and editable.

                  这里有一个示例:

                      var drawnItems = new L.FeatureGroup();
                      map.addLayer(drawnItems);
                  
                      var polyLayers = [];
                  
                      var polygon1 = L.polygon([
                          [51.509, -0.08],
                          [51.503, -0.06],
                          [51.51, -0.047]
                      ]);
                      polyLayers.push(polygon1)
                  
                      var polygon2 = L.polygon([
                          [51.512642, -0.099993],
                          [51.520387, -0.087633],
                          [51.509116, -0.082483]
                      ]);
                      polyLayers.push(polygon2)
                  
                      // Add the layers to the drawnItems feature group 
                      for(let layer of polyLayers) {
                          drawnItems.addLayer(layer); 
                      }
                  

                  这篇关于将现有的传单多边形添加到现有的传单图层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:传单只加载一个瓷砖 下一篇:react-leaflet 创建自定义组件

                  相关文章

                  最新文章

                • <tfoot id='1N9fu'></tfoot><legend id='1N9fu'><style id='1N9fu'><dir id='1N9fu'><q id='1N9fu'></q></dir></style></legend>

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

                  <small id='1N9fu'></small><noframes id='1N9fu'>

                        <bdo id='1N9fu'></bdo><ul id='1N9fu'></ul>