Is there anyway to specify z-order of feature on single layer?

此生再无相见时 提交于 2019-12-04 14:39:34

Finally I got solution,Here is the final style function that will rearrange feature z-index.

`

    //function to apply color based on rtype attribute.
    function styleFunction(feature, resolution) {
      var level = feature.get('rtype');
      if (!level || !RouteType[level]) {
        return [defaultStyle];
      }
      if (!styleCache[level]) {
        styleCache[level] = new ol.style.Style({
          stroke: new ol.style.Stroke({
            color: RouteType[level],
            width: 4
          }),
          zIndex: zIndexValue
        });
      }
  // at this point, the style for the current level is in the cache
  // so return it (as an array!)
  return [styleCache[level]];
}`

you can check example here http://bl.ocks.org/wboykinm/cc509eb2763ca1ba9293

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!