In an attempt to retrieve all features (point geometry) that fall in a selected polygon, I get the error this.layer.addFeatures is not a function
. My code is as shown below:
function createWFSVector(map, WFS_HOST) {
var population = new OpenLayers.Layer.Vector("Population Vector", {
strategies: [new OpenLayers.Strategy.BBOX()],
protocol: new OpenLayers.Protocol.WFS({
version: "1.1.0",
url: WFS_HOST,
featureType: "population_layer",
featureNS: "pe_ns",
srsName: "EPSG:4326"
})
});
addMapControls(map, population);
map.addLayers([population]);
}
function addMapControls(map, wfsLayer) {
var select = new OpenLayers.Control.SelectFeature([wfsLayer], {
box: true,
multiple: true,
onSelect: addSelected,
onUnselect: clearSelected
});
map.addControl(select);
map.addControl(new OpenLayers.Control.EditingToolbar(select));
select.activate();
}
function addSelected(feature) {
selectedFeatures.push(feature);
}
function clearSelected(feature) {
selectedFeatures = [];
}
I can't seem to spot the problem with my code. Any assistance will be appreciated.
Best Answer
You've made mistake:
new OpenLayers.Control.EditingToolbar(select)
should benew OpenLayers.Control.EditingToolbar(wfsLayer)
in your case.