[OpenLayers-Users] WFS.fromWMSLayer get multiple feature attributes

rickm81 rickm81 at yahoo.com
Mon May 12 13:24:00 PDT 2014


Hello Alll,

I am trying to retrieve feature data from a WMS layer hosted by GeoServer
using a Vector layer drawn on a map. Unfortunately, I am only receiving the
NumberOfFeatures selected. For example, I draw a polygon on the map that
intersects 10 polygon features in the WMS layer. The NumberOfFeatures value
returned is 10, but none of the feature data ("ID", "ADDRESS", "POLYNUMBER",
etc.) is returned. 

Here is the code I am using to query the WMS Layer. 

// Create WMS Layer
    census_blocks = new OpenLayers.Layer.WMS("Census Block Groups",
"http://localhost:8080/geoserver/US_Census_Blocks_CensusSummary/wms",
    { 'layers':
'2010_BlockGroups_US_CensusSummary:2010_BlockGroups_US_CensusSummary',
transparent: true, format: 'image/png' },
    { isBaseLayer: false });

// Create Filter Using Polygon Drawn on Map
    var pfilter = new OpenLayers.Filter.Spatial({
        type: OpenLayers.Filter.Spatial.INTERSECTS,
        value: e.feature.geometry // <== This is the polygon drawn on map
    });

// Create WFS From WMS, Pass in Filter, Handle Response
    var wfsProtocol = new
OpenLayers.Protocol.WFS.fromWMSLayer(census_blocks);
    wfsProtocol.read({
        filter: pfilter,
        extractAttributes: true,
        infoFormat: "application/vnd.ogc.gml",
        resultType: "hits",
        callback: function (resp) {
            // Trying to access Feature Data here, but unsuccessful
            alert(resp);
        }
    });

I've looked at several examples online, but have not found a resolution. If
any one has any ideas I would greatly appreciate it. Thank you!





--
View this message in context: http://osgeo-org.1560.x6.nabble.com/WFS-fromWMSLayer-get-multiple-feature-attributes-tp5139854.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list