2016-03-03 33 views
0

我有物品包在我的lines1物品發送到傳單。如何從傳單中讀取JsonObj的屬性?

當遍歷JsonObj routesMap數組時,我如何與這些屬性相關?

function setDddCallback() { 
    $('select[name="dropdown"]').change(function() { 
    //  var item = this.selectedIndex; 
    var value = this.value; 
    routesLayerGroup.eachLayer(function(layer) { 
     try { 
     if (layer.feature.geometry.properties.alt_id == value) { 
      highlightFeature({ 
      "target": layer 
      }) 
     } else { 
      resetHighlight({ 
      "target": layer 
      }) 
     } 
     } catch (e) {} 
    }); 
    }); 
} 

在我的代碼layer.featureundefined

enter image description here

回答

0

layer.feature.geometry.properties =>根據GeoJSON的規範,只有特色預期潛在地具有properties

從上一個問題看來,您的GeoJSON對象似乎是幾何圖形,而不是特徵。這就是爲什麼Leaflet沒有將feature成員附加到內置的layerlayer.featureundefined