久久久久久久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 層添加控制的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

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

                  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

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

                  This thread describes a similar problem, and user ddproxy said

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

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

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

                  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.

                  以下是相關代碼:

                  <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 方法).如果子圖層是非組圖層,則將其添加到您的可編輯要素組.如果是另一個嵌套組,則再次循環(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 個其他解決方案重構您的代碼:

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

                  • 而不是構建您的 layerGroup(實際上是一個 LeafletGeoJSON 圖層組),然后將其添加到您的 Hazards 功能組中,從頭開始將后者設為 GeoJSON 圖層組,然后 addData 用于您的每個功能(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
                  }
                  

                  • 您可以直接構建一個 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"};
                        }
                      }
                      

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

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

                  相關文檔推薦

                  Check if a polygon point is inside another in leaflet(檢查一個多邊形點是否在傳單中的另一個內(nèi)部)
                  Changing leaflet markercluster icon color, inheriting the rest of the default CSS properties(更改傳單標記群集圖標顏色,繼承其余默認 CSS 屬性)
                  Trigger click on leaflet marker(觸發(fā)點擊傳單標記)
                  How can I change the default loading tile color in LeafletJS?(如何更改 LeafletJS 中的默認加載磁貼顏色?)
                  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>

                            主站蜘蛛池模板: 亚洲欧美精品国产一级在线 | 国产乱码久久久久久一区二区 | 亚洲夜夜爽 | 久久久青草婷婷精品综合日韩 | 九九热精品在线视频 | 亚洲欧美中文日韩在线v日本 | www一级片 | 久久免费大片 | 一区二区在线不卡 | 91最新入口 | 久久久久久久久久爱 | 免费看av大片 | 丁香六月激情 | 午夜综合 | jav成人av免费播放 | 免费观看成人性生生活片 | 国产乱码一区 | 欧美午夜精品久久久久久浪潮 | 日日夜夜精品视频 | 日韩免费视频 | 丝袜一区二区三区 | 欧美亚洲在线 | 国产成人免费视频网站高清观看视频 | 日日操夜夜操天天操 | 妖精视频一区二区三区 | 精品九九| 国产精品一区二区三区久久久 | 久久中文字幕av | 国产精品久久久久一区二区三区 | 羞羞的视频免费看 | 精品一区二区三区四区 | 欧美一区永久视频免费观看 | 国产成人在线播放 | 人人干人人草 | www.狠狠干| 日本免费黄色一级片 | 国产精品免费大片 | 亚洲成人99| av免费网站在线观看 | 久久国| 蜜月aⅴ国产精品 |