久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

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

  • <small id='vfnox'></small><noframes id='vfnox'>

    <legend id='vfnox'><style id='vfnox'><dir id='vfnox'><q id='vfnox'></q></dir></style></legend>

        <bdo id='vfnox'></bdo><ul id='vfnox'></ul>
      <tfoot id='vfnox'></tfoot>

        傳單繪制“無法讀取未定義的屬性‘啟用’&quo

        Leaflet Draw quot;Cannot read property #39;enable#39; of undefinedquot; adding control to geoJSON layer(傳單繪制“無法讀取未定義的屬性‘啟用’向 geoJSON 層添加控制)

          <tbody id='hE63V'></tbody>
        1. <legend id='hE63V'><style id='hE63V'><dir id='hE63V'><q id='hE63V'></q></dir></style></legend>

              <tfoot id='hE63V'></tfoot>

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

                • <bdo id='hE63V'></bdo><ul id='hE63V'></ul>
                  <i id='hE63V'><tr id='hE63V'><dt id='hE63V'><q id='hE63V'><span id='hE63V'><b id='hE63V'><form id='hE63V'><ins id='hE63V'></ins><ul id='hE63V'></ul><sub id='hE63V'></sub></form><legend id='hE63V'></legend><bdo id='hE63V'><pre id='hE63V'><center id='hE63V'></center></pre></bdo></b><th id='hE63V'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='hE63V'><tfoot id='hE63V'></tfoot><dl id='hE63V'><fieldset id='hE63V'></fieldset></dl></div>
                  本文介紹了傳單繪制“無法讀取未定義的屬性‘啟用’"向 geoJSON 層添加控制的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我正在嘗試對(duì)從數(shù)據(jù)庫加載的多邊形使用傳單的編輯功能.當(dāng)我單擊傳單的編輯按鈕時(shí),我收到錯(cuò)誤
                  無法讀取未定義的屬性啟用"

                  I am trying to use leaflet's edit function on polygons that I loaded from my database. When I click on leaflet's edit button I get the error
                  Cannot read property 'enable' of undefined

                  這個(gè)帖子描述了一個(gè)類似的問題,用戶ddproxy說

                  This thread describes a similar problem, and user ddproxy said

                  由于FeatureGroup擴(kuò)展了LayerGroup,你可以遍歷圖層呈現(xiàn)并將它們單獨(dú)添加到用于Leaflet.draw"

                  "Since FeatureGroup extends LayerGroup You can walk through the layers presented and add them individually to the FeatureGroup used for Leaflet.draw"

                  我很困惑他所說的穿過"是什么意思,我以為我正在添加一個(gè)圖層組,所以我不確定我會(huì)穿過什么.這是否與我將多邊形添加為 geoJSON 對(duì)象這一事實(shí)有關(guān)?
                  將多邊形添加到地圖,綁定它們的彈出窗口,并為它們分配自定義顏色,僅供參考.

                  I am confused what he means by "walk through", I thought I was adding a layer group, so i'm not sure what I would be walking through. Does this have to do with the fact that i'm adding the polygons as a geoJSON object?
                  Adding the polygons to the map, binding their popups, and assigning them custom colors works perfectly FYI.

                  以下是相關(guān)代碼:

                  <script>
                  window.addEventListener("load", function(event){
                      //other stuff
                      loadHazards(); 
                  
                  });
                  
                  //next 6 lines siply add map to page
                  var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'
                  var osmAttrib = '&copy; <a >OpenStreetMap</a> contributors'
                  var osm = L.tileLayer(osmUrl, { maxZoom: 18, attribution: osmAttrib})
                  var map = new L.Map('map', { center: new L.LatLng(39.255467, -76.711964), zoom: 16 })
                  
                  osm.addTo(map);
                  
                  var drawnItems = L.featureGroup().addTo(map);
                  var Hazards = L.featureGroup().addTo(map);
                  
                  L.control.layers({
                          'osm': osm.addTo(map)
                          },
                          {
                             'drawlayer': drawnItems,
                             "Hazards" : Hazards,
                             "Tickets": Tickets
                           },
                  
                           {
                             position: 'topleft', collapsed: false
                           }
                           ).addTo(map);
                  
                  map.addControl(new L.Control.Draw({
                      edit: {
                          featureGroup: Hazards,
                          poly: {
                              allowIntersection: false
                          }
                      },
                      draw: {
                          polygon: {
                              allowIntersection: false,
                              showArea: true
                          },
                          rectangle:false,
                          circle:false,
                          circlemarker:false
                      }
                  }));
                  
                  map.on(L.Draw.Event.CREATED, function (event) {
                      var layer = event.layer;
                      drawnItems.addLayer(layer);
                  });
                  
                  </script>
                  

                  還有 loadHazards() 函數(shù):

                  And the loadHazards() function:

                  function loadHazards(){
                  $.ajax({
                      type: 'GET',
                      url:'/loadPolygonFromDatabase',
                      success : function(polygons){           
                          polygons = JSON.parse(polygons);
                  
                          var toAdd = [];
                          for (i in polygons){
                  
                              var item = {
                                      "type" : "Feature",
                                      "properties":{
                                          "category":"",
                                          "description":"",
                                          "ID":""
                                       },
                                       "geometry" : {
                                          "type":"Polygon",
                                          "coordinates":[],
                  
                                      }
                  
                              };
                  
                              item["geometry"]["coordinates"][0] = polygons[i]["coordinates"];
                              item["properties"]["category"]     = polygons[i]["category"];
                              item["properties"]["description"]  = polygons[i]["description"];
                              item["properties"]["ID"]  = polygons[i]["ID"];
                              toAdd.push(item);
                  
                          }
                  
                          //Add information to popup
                          var layerGroup = L.geoJSON(toAdd, {
                              onEachFeature: function (feature, layer) {
                                  layer.bindPopup(  '<h1>' + feature.properties.category + '</h1>'
                                                  + '<p>'  + feature.properties.description + '</p>');
                                  layer.id = feature.properties.ID;
                  
                            },
                            style: function(feature){
                               switch (feature.properties.category) {
                                  case 'Rabid_Beavers': return {color: "#663326"};
                                  case 'Fire':   return {color: "#ff0000"};
                                  case 'Flood':   return {color: "#0000ff"};
                              }
                            }
                          }).addTo(Hazards);
                  
                      }
                  });
                  }
                  

                  提前致謝!

                  推薦答案

                  不幸的是,Leaflet.draw 插件不處理嵌套層組(功能組/GeoJSON 層組相同).

                  Unfortunately Leaflet.draw plugin does not handle nested Layer Groups (same for Feature Groups / GeoJSON Layer Groups).

                  這就是你參考的Leaflet.draw #398問題的意思:他們建議遍歷您的 Layer/Feature/GeoJSON 層組的 child 層(例如,使用他們的 eachLayer 方法).如果子圖層是非組圖層,則將其添加到您的可編輯要素組.如果是另一個(gè)嵌套組,則再次循環(huán)遍歷其自己的子層.

                  That is the meaning of the Leaflet.draw #398 issue you reference: they advise looping through the child layers of your Layer/Feature/GeoJSON Layer Group (e.g. with their eachLayer method). If the child layer is a non-group layer, then add it to your editable Feature Group. If it is another nested group, then loop through its own child layers again.

                  查看該帖子中提出的代碼:

                  See the code proposed in that post:

                  https://gis.stackexchange.com/questions/203540/how-to-edit-an-existing-layer-using-leaflet

                  var geoJsonGroup = L.geoJson(myGeoJSON);
                  addNonGroupLayers(geoJsonGroup, drawnItems);
                  
                  // Would benefit from https://github.com/Leaflet/Leaflet/issues/4461
                  function addNonGroupLayers(sourceLayer, targetGroup) {
                    if (sourceLayer instanceof L.LayerGroup) {
                      sourceLayer.eachLayer(function(layer) {
                        addNonGroupLayers(layer, targetGroup);
                      });
                    } else {
                      targetGroup.addLayer(sourceLayer);
                    }
                  }
                  

                  在您的情況下,您還可以使用 2 個(gè)其他解決方案重構(gòu)您的代碼:

                  In your very case, you can also refactor your code with 2 other solutions:

                  • 而不是構(gòu)建您的 layerGroup(實(shí)際上是一個(gè) LeafletGeoJSON 圖層組),然后將其添加到您的 Hazards 功能組中,從頭開始將后者設(shè)為 GeoJSON 圖層組,然后 addData 用于您的每個(gè)功能(item):
                  • Instead of building your layerGroup (which is actually a Leaflet GeoJSON Layer Group) first and then add it into your Hazards Feature Group, make the latter a GeoJSON Layer Group from the beginning, and addData for each of your single Features (item):
                  var Hazards = L.geoJSON(null, yourOptions).addTo(map);
                  
                  for (i in polygons) {
                    var item = {
                      "type" : "Feature",
                      // etc.
                    };
                    // toAdd.push(item);
                    Hazards.addData(item); // Directly add the GeoJSON Feature object
                  }
                  

                  • 您可以直接構(gòu)建一個(gè) Leaflet Polygon 并將其添加到您的 Hazards 圖層/功能組中:
                    • Instead of building a GeoJSON Feature Object (item) and parse it into a Leaflet GeoJSON Layer, you can directly build a Leaflet Polygon and add it into your Hazards Layer/Feature Group:
                    • for (i in polygons) {
                        var coords = polygons[i]["coordinates"];
                        var style = getStyle(polygons[i]["category"]);
                        var popup = ""; // fill it as you wish
                      
                        // Directly build a Leaflet layer instead of an intermediary GeoJSON Feature
                        var itemLayer = L.polygon(coords, style).bindPopup(popup);
                        itemLayer.id = polygons[i]["ID"];
                        itemLayer.addTo(Hazards);
                      }
                      
                      function getStyle(category) {
                        switch (category) {
                          case 'Rabid_Beavers': return {color: "#663326"};
                          case 'Fire':   return {color: "#ff0000"};
                          case 'Flood':   return {color: "#0000ff"};
                        }
                      }
                      

                      這篇關(guān)于傳單繪制“無法讀取未定義的屬性‘啟用’"向 geoJSON 層添加控制的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                      【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Check if a polygon point is inside another in leaflet(檢查一個(gè)多邊形點(diǎn)是否在傳單中的另一個(gè)內(nèi)部)
                  Changing leaflet markercluster icon color, inheriting the rest of the default CSS properties(更改傳單標(biāo)記群集圖標(biāo)顏色,繼承其余默認(rèn) CSS 屬性)
                  Trigger click on leaflet marker(觸發(fā)點(diǎn)擊傳單標(biāo)記)
                  How can I change the default loading tile color in LeafletJS?(如何更改 LeafletJS 中的默認(rèn)加載磁貼顏色?)
                  Add external geojson to leaflet layer(將外部geojson添加到傳單層)
                  Adding Leaflet layer control to sidebar(將 Leaflet 圖層控件添加到側(cè)邊欄)
                    <tfoot id='QpQ9c'></tfoot>
                        <tbody id='QpQ9c'></tbody>

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

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

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

                            主站蜘蛛池模板: 成人欧美一区二区三区白人 | 黄色特级毛片 | 天天射天天干天天操 | 日本伊人网 | 亚洲成人精品在线 | 黄视频在线播放 | 国产一级一片免费播放放a 男男成人高潮片免费网站 精品视频在线观看 | 毛片aaa| 久久久xxx | 国产伦理一区二区 | 亚洲精品一区中文字幕乱码 | 久久av红桃一区二区小说 | 老司机深夜福利视频 | 亚洲小视频 | 欧美国产日韩在线 | 成人在线观看视频网站 | 久久综合99 | 国产成人97精品免费看片 | 亚洲视频免费观看 | 看片地址 | 国产精品美女久久久久久久久 | 日韩成人免费 | 午夜看片| 自拍视频一区 | 日韩一级免费视频 | 色啪视频 | 一级片在线免费观看 | 亚洲欧美中文字幕 | 国产小视频在线播放 | 国产午夜一区二区 | 亚洲天堂第一页 | 亚洲男人天堂网 | 亚洲精品少妇 | av大全在线观看 | 精品视频久久 | 日本中文字幕一区 | 日韩精品中文字幕在线观看 | 日韩午夜精品 | 国产一区二区中文字幕 | 久久人人爽人人爽人人片 | 日韩三级一区 |