[OpenLayers-Users] Conversion of BBox for GetFeature Request

Gery . gamejihou at hotmail.com
Wed Mar 6 13:48:02 PST 2013


Hi Jerome,

Not sure here, but seems to me that the problem is the events.register, try this to see what is going on there:

myControl.events.register("featureselected", this, function(e) {
                                highlightLayer.addFeatures(e.features);
console.log("THIS HAS BEEN ADDED: " + e.features);
                });
                myControl.events.register("featureunselected", this, function(e) {
                                highlightLayer.removeFeatures(e.features);
console.log("THIS HAS BEEN DELETED: " + e.features);

Try some variants inside the parentheses of each console.log call.

Sent from my iBath

On Mar 6, 2013, at 22:38, "Jerome A. Wendell" <jawendell at digitalmapping.com> wrote:

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:
<image001.png>
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.
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130306/1d1cd42f/attachment-0001.html>


More information about the Users mailing list