javascript - OpenLayers: how can be ol.FeatureOverlay replaced in 3.13v? - Stack Overflow

Here there is an overlay feature example.It doesn't work on 3.13 OpenLayers version because of no

Here there is an overlay feature example.

It doesn't work on 3.13 OpenLayers version because of no more supported ol.FeatureOverlay.

How can be it replaced? Could you give me an example?

Here there is an overlay feature example.

It doesn't work on 3.13 OpenLayers version because of no more supported ol.FeatureOverlay.

How can be it replaced? Could you give me an example?

Share Improve this question asked Mar 7, 2016 at 12:30 Sefran2Sefran2 3,58813 gold badges73 silver badges108 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 7

Copied & Pasted from changelog/v3.7.0.md

Instead of an ol.FeatureOverlay, we now use an ol.layer.Vector with an ol.source.Vector. If you previously had:

var featureOverlay = new ol.FeatureOverlay({
  map: map,
  style: overlayStyle
});
featureOverlay.addFeature(feature);
featureOverlay.removeFeature(feature);
var collection = featureOverlay.getFeatures();

you will have to change this to:

var collection = new ol.Collection();
var featureOverlay = new ol.layer.Vector({
  map: map,
  source: new ol.source.Vector({
    features: collection,
    useSpatialIndex: false // optional, might improve performance
  }),
  style: overlayStyle,
  updateWhileAnimating: true, // optional, for instant visual feedback
  updateWhileInteracting: true // optional, for instant visual feedback
});
featureOverlay.getSource().addFeature(feature);
featureOverlay.getSource().removeFeature(feature);

I had the same issue. There is an updated example on OpenLayers website for the latest version (Vector Layer - v3.14.2) where features are highlighted on mouseover.

For OL 6.3.1 Vector Layer demonstrates the highlighting on mouseover

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745194696a4616033.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信