私はOL2からOL3にプロジェクトを更新していますが、フィーチャスタイルを変更した後に、フィーチャを再描画する方法については固執しています。 OL2でオープンレイヤー3でフィーチャーを非表示にして表示する方法は?
が、これは働いていた:)OL3で
hidePoints: function(id) {
if (! this.getMap().center) {
return;
}
var i,
feature,
len = this.points.features.length;
if (id !== null) {
for(i = 0; i < len; i++) {
feature = this.points.features[i];
if (feature.attributes.aces_id == id) {
feature.style = null;
} else {
feature.style = { display: 'none' };
}
}
} else {
for(i = 0; i < len; i++) {
feature = this.points.features[i];
feature.style = { display: 'none' };
}
}
this.points.redraw();
},
を、私はポイントレイヤを非表示にする機能を更新しようとしたが、(再描画もう存在しないし、私が働いている層は、オールであるから。ベクトル。私はベクトル以外の他のソースのようなupdateParamsオプションを見つけることができません。ディスパッチイベントと変更も機能しませんでした。私は変更を望んでいたが、何も起こらない。スタイルを変更する(別のVARの各機能を取得する)この方法で行わ場合、またはされている場合、私も思ったんだけど
hidePoints: function(id) {
if (! this.getMap().getView().getCenter()) {
return;
}
var i,
feature,
layerSourceFeatures = this.pointsLayer.getSource().getFeatures(),
len = layerSourceFeatures.length;
if (id !== null) {
for(i = 0; i < len; i++) {
feature = this.pointsLayer.getSource().getFeatures()[i];
if (feature.get('aces_id') == id) {
feature.style = null;
} else {
feature.style = { display: 'none' };
}
}
} else {
for(i = 0; i < len; i++) {
feature = this.pointsLayer.getSource().getFeatures()[i];
feature.style = { display: 'none' };
}
}
//this.pointsLayer.redraw();
//this.pointsLayer.dispatchEvent(goog.events.EventType.CHANGE);
this.pointsLayer.changed();
},
それは単にその機能を変更し、元のそのままを残すことはありません。 Plusは常にgetSource()を取得します。getFeatures()はパフォーマンスに悪いと思われますが、私は別の方法を見つけることができません。
OL3では、どのようにスタイルを変更したフィーチャをレンダリングするかは関係ありません。レイヤーは表示可能に設定することができますが、すべてのフィーチャを常に非表示にする/表示したくありません。時には、私はちょうど彼らの与えられたidに応じていくつかを隠す/表示したいです。
てくれてありがとうコメントですが、これは私が探していたものではなく、効率的でないフィーチャごとのレイヤーを追加することになります。 – Ada