I am currently using addFeatures
and removeAllFeatures
in my code to get the desired results and this is working OK.
However, I have been asked to ensure that the vector layers are not being recreated each time. "They should be loading new data not creating new layers." I'm in no position to argue, and I really think the way I have it set up via removing/adding is pretty decent.
The type of data is airplane data in an AJAX call. The airplane moves along its flight path.
3 layers in question: the airplane layer, the projected flight path, and the travelled flight path.
Currently I have something like so:
if (vectors_airplane != "" || vectors_projected_path != "" || vectors_flown_path != "") {
vectors_projected_path.removeAllFeatures([projected_path]);
vectors_flown_path.removeAllFeatures([tail_path]);
vectors_airplane.removeAllFeatures([airplane]);
}
and then for adding (within the same ajax call):
vectors_flown_path.addFeatures([tail_path]);
vectors_projected_path.addFeatures([projected_path]);
vectors_airplane.addFeatures([airplane]);
These are vector layers but there is no associated WFS. It seems to use the refresh
strategy appropriately there must be a WFS Protocol (please correct me if I am wrong). I don't want to add a WFS protocol to each layer here, as it seems unnecessary.
The goal: how to change this logic to not use removeAllFeatures and addFeatures and instead use refresh/redraw?