pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

  • <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="lkwastu" 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="ue8rmv2" 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)益,請聯(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="mtw318v" 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>

                            主站蜘蛛池模板: 生产加气砖设备厂家很多,杜甫机械加气砖设备价格公道 | sus630/303cu不锈钢棒,440C/430F/17-4ph不锈钢研磨棒-江苏德镍金属科技有限公司 | 广东西屋电气有限公司-广东西屋电气有限公司 | 猎头招聘_深圳猎头公司_知名猎头公司| 污水/卧式/潜水/钻井/矿用/大型/小型/泥浆泵,价格,参数,型号,厂家 - 安平县鼎千泵业制造厂 | 防火阀、排烟防火阀、电动防火阀产品生产销售商-德州凯亿空调设备有限公司 | SMC-ASCO-CKD气缸-FESTO-MAC电磁阀-上海天筹自动化设备官网 | 网站建设,北京网站建设,北京网站建设公司,网站系统开发,北京网站制作公司,响应式网站,做网站公司,海淀做网站,朝阳做网站,昌平做网站,建站公司 | 拉伸膜,PE缠绕膜,打包带,封箱胶带,包装膜厂家-东莞宏展包装 | 电车线(用于供电给电车的输电线路)-百科 | 通风天窗,通风气楼,屋顶通风天窗,屋顶通风天窗公司 | 东莞螺杆空压机_永磁变频空压机_节能空压机_空压机工厂批发_深圳螺杆空压机_广州螺杆空压机_东莞空压机_空压机批发_东莞空压机工厂批发_东莞市文颖设备科技有限公司 | 餐饮加盟网_特色餐饮加盟店_餐饮连锁店加盟 | 东莞螺丝|东莞螺丝厂|东莞不锈钢螺丝|东莞组合螺丝|东莞精密螺丝厂家-东莞利浩五金专业紧固件厂家 | 吲哚菁绿衍生物-酶底物法大肠菌群检测试剂-北京和信同通科技发展有限公司 | 安平县鑫川金属丝网制品有限公司,声屏障,高速声屏障,百叶孔声屏障,大弧形声屏障,凹凸穿孔声屏障,铁路声屏障,顶部弧形声屏障,玻璃钢吸音板 | 膜结构停车棚-自行车棚-膜结构汽车棚加工安装厂家幸福膜结构 | 数控车床-立式加工中心-多功能机床-小型车床-山东临沂金星机床有限公司 | 百方网-百方电气网,电工电气行业专业的B2B电子商务平台 | 合肥制氮机_合肥空压机厂家_安徽真空泵-凯圣精机 | 保温杯,儿童婴童奶瓶,运动水壶「广告礼品杯定制厂家」超朗保温杯壶 | 南京展台搭建-南京展会设计-南京展览设计公司-南京展厅展示设计-南京汇雅展览工程有限公司 | 光栅尺_Magnescale探规_磁栅尺_笔式位移传感器_苏州德美达 | 砂尘试验箱_淋雨试验房_冰水冲击试验箱_IPX9K淋雨试验箱_广州岳信试验设备有限公司 | 洛阳永磁工业大吊扇研发生产-工厂通风降温解决方案提供商-中实洛阳环境科技有限公司 | 杭州ROHS检测仪-XRF测试仪价格-百科 | 中药二氧化硫测定仪,食品二氧化硫测定仪|俊腾百科| 20年条刷老厂-条刷-抛光-工业毛刷辊-惠众毛刷 | EFM 022静电场测试仪-套帽式风量计-静电平板监测器-上海民仪电子有限公司 | 合肥钣金加工-安徽激光切割加工-机箱机柜加工厂家-合肥通快 | 广东恩亿梯电源有限公司【官网】_UPS不间断电源|EPS应急电源|模块化机房|电动汽车充电桩_UPS电源厂家(恩亿梯UPS电源,UPS不间断电源,不间断电源UPS) | 安徽合肥项目申报咨询公司_安徽合肥高新企业项目申报_安徽省科技项目申报代理 | 电磁辐射仪-电磁辐射检测仪-pm2.5检测仪-多功能射线检测仪-上海何亦仪器仪表有限公司 | 不锈钢复合板|钛复合板|金属复合板|南钢集团安徽金元素复合材料有限公司-官网 | 酶联免疫分析仪-多管旋涡混合仪|混合器-莱普特科学仪器(北京)有限公司 | 不锈钢拉手厂家|浴室门拉手厂家|江门市蓬江区金志翔五金制品有限公司 | 生态板-实木生态板-生态板厂家-源木原作生态板品牌-深圳市方舟木业有限公司 | 空气能采暖,热泵烘干机,空气源热水机组|设备|厂家,东莞高温热泵_正旭新能源 | 小程序开发公司_APP开发多少钱_软件开发定制_微信小程序制作_客户销售管理软件-济南小溪畅流网络科技有限公司 | 东风体检车厂家_公共卫生体检车_医院体检车_移动体检车-锦沅科贸 | 净气型药品柜-试剂柜-无管道净气型通风柜-苏州毕恩思 |