for (Layer layer : map.getLayers()) {
if (layer instanceof Vector) {
final Vector vectorLayer = (Vector) layer;
if(vectorLayer.getFeatureDataLoadedListeners() != null
&& vectorLayer.getFeatureDataLoadedListeners().size() > 0) {
// add a behavior to be notified when new data is loaded
VectorFeatureDataLoadedListener vectorFeatureDataLoadedListener =
new VectorFeatureDataLoadedListener(vectorLayer) {
@Override
public void handleDataLoaded(AjaxRequestTarget target, JsonArray features) {
vectorLayer.notifyFeatureDataLoadedListeners(target, features);
}
};
add(vectorFeatureDataLoadedListener);
// map the layer to the data loaded handler
layerDataLoadedMap.put(layer, vectorFeatureDataLoadedListener);
}
if(vectorLayer.getFeaturesLoadedListeners() != null
&& vectorLayer.getFeaturesLoadedListeners().size() > 0) {
// add a behavior to be notified when new features are loaded
VectorFeaturesLoadedListener vectorFeatureLoadedListener =
new VectorFeaturesLoadedListener(vectorLayer) {
@Override
public void handleDataLoaded(AjaxRequestTarget target) {
vectorLayer.notifyFeaturesLoadedListeners(target);
}
};
add(vectorFeatureLoadedListener);
// map the layer to the data loaded handler