New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blink (when refresh) and duplicate (when move) - Features on vector layer #4558
Comments
Duplicate features (at loading strategy bbox) problem omited by change: What about blink at refresh layer? Is there any solution? |
When you have unique ids on your features, there should be no duplicates. Maybe double-check if they are really as fid when you get the data from your server. The classic solution for avoiding blink effects is to use two sources, and switch from the old source to the new source when the features are loaded. And yes, call Also, your code could be simplified by just using a |
Use two sources and switch between... it's gently complicated, would be nice to have simpler solution. Thx for new OL3 |
It's not that complicated. Look at this fiddle: http://jsfiddle.net/ahocevar/tLt5wdpz/. |
I have a problem with refresh vector layer every X seconds. I was looking solutions many times without luck. I have code but with blink effect (blinking features, when I clear old and add new features):
[OL v 3.11.2]
var sourceVector = new ol.source.Vector({
loader: function(extent) {
$.ajax('http://server/wfs_ant',{
type: 'GET',
data: {
service: 'WFS',
version: '1.1.0',
request: 'GetFeature',
typename: 'v_wezel_rfid',
srsname: 'EPSG:3857',
bbox: extent.join(',') + ',EPSG:3857'
},
}).done(loadFeatures);
},
strategy: ol.loadingstrategy.bbox
});
var loadFeatures = function(response) {
formatWFS = new ol.format.WFS(),
//sourceVector.clear();
sourceVector.addFeatures(formatWFS.readFeatures(response));
console.log('loadFeatures');
};
function refresh(sourceVector){
sourceVector.clear();
sourceVector;
console.log(' refresh');
}
var layerVector = new ol.layer.Vector({
source: sourceVector,
style: vectorStyle
});
setInterval(function(){refresh(sourceVector); }, 10000);
I was trying remove: sourceVector.clear() in loadFeature section but then loading wfs features going on endless loop.
Second problem is duplicate features, when move map there show duplicate features and duplicate are add every move map. I have unique id on wfs.
The text was updated successfully, but these errors were encountered: