[OpenLayers-Users] WMS/WFS getfeature on hover, problem to display the GML

Martin Ouellet geomartino at gmail.com
Fri May 29 08:46:45 EDT 2009


Hi Alex,
here's some piece of the code:
// vector layer
layerHover = new OpenLayers.Layer.Vector("Hover");

// wms/wfs layer
layerWMS  =  new OpenLayers.Layer.WMS(
                          "regions WMS",
                          "
http://spssoww5d.sso.msp.gouv.qc.ca/cgi-wms/mapserv.exe?map=E:/ms4w/msp/wfs/botinSI.map&
",
                          {layers: 'BDGA_REGIO_S_POLY_1M',
                           format: 'image/gif',
                           transparent: true,
                           visibility: true
                          }
                          );

 //control to launch wfs call on hover
 control = new OpenLayers.Control.GetFeature({
                protocol: OpenLayers.Protocol.WFS.fromWMSLayer(layerWMS),
                hover: true
            });

//never called, see explanation below
control.events.register("hoverfeature", this, function(e) {
                layerHover.addFeatures([e.feature]);
            });


As I said, The WFS call is maded on hover and I can see the GML in the
response.  In the request function of the GetFeature.js file:
result.features = void BUT
result.priv.responseText contain the GML response

so when this function is called, nothing happens since result.features is
null/void

request: function(bounds, options) {
        options = options || {};
        var filter = new OpenLayers.Filter.Spatial({
            type: OpenLayers.Filter.Spatial.BBOX,
            value: bounds
        });

        var response = this.protocol.read({
            maxFeatures: options.single == true ? this.maxFeatures :
undefined,
            filter: filter,
            callback: function(result) {
                if(result.code == 1) {

                    if(result.features.length) {
                        if(options.single == true) {
                            this.selectBestFeature(result.features,
                                bounds.getCenterLonLat(), options);
                        } else {
                            this.select(result.features);
                        }
                    } else if(options.hover) {
                        this.hoverSelect();
                    } else {
                        this.events.triggerEvent("clickout");
                        if(this.clickout) {
                            this.unselectAll();
                        }
                }
                // Reset the cursor.
                OpenLayers.Element.removeClass(this.map.div,
"olCursorWait");
            },
            scope: this
        });
        if(options.hover == true) {
            this.hoverRequest = response.priv;
        }
    },


2009/5/29 Alexandre Dube <adube at mapgears.com>

> Hi Martin,
>
>  It could be a namespace issue.  It would be easier to help if your code.
>  The vector layer object should be enough.
>
> Regards,
>
> Alexandre
>
> Martin Ouellet wrote:
>
>> Hi all,
>>
>> I'am using the getfeature example (getfeature-wfs.html) with my data
>> (mapserver + shp).  The WFS call il launch on the hover event and the GML is
>> return correclty (I can see it in firebug) but during the call back
>> (hoverSelect function), the parameter feature is always null (void) so the
>> GML response is not added to my vector layer.
>>
>> any suggestion?
>>
>> MartinO
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>
>>
>
>
> --
> Alexandre Dubé
> Mapgears
> www.mapgears.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090529/daeca2de/attachment.html


More information about the Users mailing list