[OpenLayers-Users] Conversion of BBox for GetFeature Request

Jerome A. Wendell jawendell at digitalmapping.com
Wed Mar 6 13:38:29 PST 2013


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.

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130306/9beb8efe/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 3270 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130306/9beb8efe/attachment.png>


More information about the Users mailing list