[Users] Problem using GetFeature with WFS.fromWMSLayer in a GeoExt mapPanel

Anne Brookes anne.brookes at jbaconsulting.co.uk
Wed Nov 17 13:27:44 CET 2010


Hello,
I am trying to implement a GetFeature control in a GeoExt map panel but cannot get it to return a selected feature (in IE 8 or Firefox 3.5.1).  I have tried a really simple example using the OpenLayers getfeature-wfs.html example and adding the map to GeoExt mapPanel, but it does not highlight a feature or add one to the vector layer, although the cursor does briefly change to a crosshair, as if something is happening.  In the application that I am writing I want to link the getfeature control to a toolbar item.
Can anyone tell me what I am doing wrong, please?
Thanks
anneb

the js code is here:
var map, layer, select, hover, control;
Ext.onReady(function() {
    OpenLayers.ProxyHost= "proxy.cgi?url=";
    Ext.BLANK_IMAGE_URL = '../ext-3.2.1/resources/images/default/s.gif';
    var options = {
                    controls: [
                    new OpenLayers.Control.PanZoom(),
                    new OpenLayers.Control.Permalink(),
                    new OpenLayers.Control.Navigation()
                    ]
                };
    map = new OpenLayers.Map('map', options);
    layer = new OpenLayers.Layer.WMS(
                "States WMS/WFS",
                "http://v2.suite.opengeo.org/geoserver/ows",
                {layers: 'usa:states', format: 'image/gif'}
            );
    select = new OpenLayers.Layer.Vector("Selection", {
        styleMap: new OpenLayers.Style(OpenLayers.Feature.Vector.style["select"])
    });
    hover = new OpenLayers.Layer.Vector("Hover");
    map.addLayers([layer, hover, select]);
    control = new OpenLayers.Control.GetFeature({
        protocol: OpenLayers.Protocol.WFS.fromWMSLayer(layer),
        box: true,
        hover: true,
        multipleKey: "shiftKey",
        toggleKey: "ctrlKey"
    });
    control.events.register("featureselected", this, function(e) {
        select.addFeatures([e.feature]);
    });
    control.events.register("featureunselected", this, function(e) {
        select.removeFeatures([e.feature]);
    });
    control.events.register("hoverfeature", this, function(e) {
        hover.addFeatures([e.feature]);
    });
    control.events.register("outfeature", this, function(e) {
        hover.removeFeatures([e.feature]);
    });
    map.addControl(control);
    control.activate();
    mapPanel = new GeoExt.MapPanel({
            title: "GeoExt MapPanel",
            renderTo: "mappanel",
            stateId: "mappanel",
            height: 400,
            width: 600,
            map: map,
            center: new OpenLayers.Bounds(-140.444336,25.115234,-44.438477,50.580078).getCenterLonLat(),
            zoom: 3
    });
});


http://www.jbaconsulting.co.uk/
 
JBA Consulting
South Barn
Broughton Hall
Skipton
North Yorkshire
BD23 3AE
United Kingdom
http://www.jbaconsulting.co.uk/?q=nce-winner-2010
t: +44 (0)1756 799919 | f: +44 (0)1756 799449 
 
JBA is a Carbon Neutral Company. Please don't print this e-mail unless you really need to.
This email is covered by JBA Consulting's http://www.jbaconsulting.co.uk/emaildisclaimer.
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20101117/f354fca0/attachment-0001.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 5104 bytes
Desc: not available
Url : http://www.geoext.org/pipermail/users/attachments/20101117/f354fca0/attachment-0002.gif 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 3793 bytes
Desc: not available
Url : http://www.geoext.org/pipermail/users/attachments/20101117/f354fca0/attachment-0003.gif 


More information about the Users mailing list