I was having a difficult time getting the code to work for a box selection, so I decided to set it up for selection on click. The click selection actually works better for my particular situation. The control is now returning features, but there seems to be a problem with adding them to the highlight layer. The code that I am using is below:
var highlightLayer = new OpenLayers.Layer.Vector("Highlighted Features", {
styleMap: myStyles,
displayInLayerSwitcher: false,
isBaseLayer: false
}
);
OpenLayers.Control.myGetFeature =
OpenLayers.Class(OpenLayers.Control.GetFeature,{
selectClick:
function(evt){
var layerSRSgeo = new OpenLayers.Projection('EPSG:4326');
var baseSRSmer = new OpenLayers.Projection('EPSG:900913');
var bounds = this.pixelToBounds(evt.xy).transform(baseSRSmer,layerSRSgeo);
this.request(bounds, {single: this.single});
},
CLASS_NAME:
'OpenLayers.Control.myGetFeature'
});
var myControl = new OpenLayers.Control.myGetFeature({
protocol:
OpenLayers.Protocol.WFS.fromWMSLayer(mylayer),
box: false,
hover: false,
maxFeatures: 40,
clickTolerance: 1
});
myControl.events.register("featureselected", this, function(e) {
highlightLayer.addFeatures(e.features);
});
myControl.events.register("featureunselected", this,
function(e) {
highlightLayer.removeFeatures(e.features);
});
map.addControl(myControl);
myControl.activate();
The error that I now get is below:
I have been working on troubleshooting this issue for quite a while and have
been searching for an answer. So far I have been unsuccessful in getting the
selected features added to the highlight layer.
Any suggestions that you might have are greatly appreciated.
Thanks.
<<image001.png>>
_______________________________________________ Users mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/openlayers-users
