【问题标题】:Compare getValue with map.layers[i].name比较 getValue 和 map.layers[i].name
【发布时间】:2014-12-15 17:17:59
【问题描述】:

作为 xtype 组合的一部分,我想知道我在简单数据存储中选择的图层(由 this.getValue() 表示)是否存在于地图图层中。因此,如果确实如此,则应该出现A,如果没有出现B。问题是 myLayer 变量似乎无法识别,即使 Opera Dragonify 根本没有抛出任何错误。哪里会出错?

listeners: {
  'select': function(combo, record) {
    for(var i = 0; i < mapPanel.map.length; i++) {
      var myLayer = mapPanel.map.layers[i].name;
      if (myLayer == this.getValue()) {
        // do A here...
      } else {
        // do B here...
      }
    }
  }
}

感谢大家的指点,

【问题讨论】:

    标签: extjs openlayers extjs3 geoext


    【解决方案1】:

    我认为问题在于您使用的是this.getValue() 而不是combo.getValue()。 我不知道您的应用程序是如何设置的,但通常最好使用侦听器的第一个参数而不是键 this 以避免范围问题。

    希望对你有帮助

    【讨论】:

      【解决方案2】:

      @Guilherme Lopes 谢谢你,但解决方案是:mapPanel.map.layers.length 而不是 mapPanel.map.length

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-10-18
        • 2011-05-09
        • 2019-11-06
        • 1970-01-01
        • 2021-05-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多