如何为openlayers3中的每个功能设置最大分辨率

how to set max resolution for each features in openlayers3

你好,我正在尝试为不同的功能做不同的样式,我得到了并且工作正常,现在我想为不同的设置不同的分辨率 features.I 试过这样做但不是 working.Can 你好帮这个?

style: function (feature, resolution) {
            //var test = (resolution >= 200) ? (feature.get('class') === 'xx') : '';
            //resolution: test;

            if (feature.get('class') === '---') {

                max Resolution: 100;
                return style1;
            }
            else if (feature.get('class') === 'xx')
            {

                return Style2;
            }
            else if (feature.get('class') === '---')
            {

                return style3;

            }
            else if(feature.get('class')==='ii')
            {

                return style4;
            }
            else if(feature.get('class')==='mm')
            {
                return style5;
            }
        },

您应该能够使用简单的布尔逻辑来解决这个问题。像这样:

style: function(feature, resolution) {
  var class = feature.get('class');
  if (resolution >= 200) {
    if (class == 'xx') {
      return style200xx;
    } else if (class == 'xy') {
      return style200xy;
    }
  } else if (resolution < 200) {
    if (class == 'xx') {
      return style0xx;
    } else if (class == 'xy') {
      return style0xy;
    }
  }
}

如果您有许多不同的情况,为每个分辨率范围定义一个单独的 ol.layer.Vector 并为所有层使用相同的 source 可能是有意义的。在样式函数中,您只需处理 class.

特征