[OpenLayers-Users] Re: Get Features from a WMS Layer

IvanBell Ivan.Bell at CCA.com
Mon May 23 21:47:41 EDT 2011


I see.  Can you elaborate just a little?  I have seen this frequently (i.e.,
the vector being created from "featureType" and "featureNS"); but no good
explanations for how to use it.


As a newbie, the OpenLayers documentation is often ambiguous, at best.  As
with this example, a lot of things are documented for an experienced reader
(as a reference) and not for a newbie (like me).


Let us say that I have the following:




------------------------------------------------------------
- map/workspace:
------------------------------------------------------------
                   Name:  MyMap
workspace namespace URI:  http://localhost:8081/MyMap

------------------------------------------------------------
- stores (vector data sources):
------------------------------------------------------------
DataSourceName:  MyLayer
           URL:  file:data/MyMap/MyLayer.shp

------------------------------------------------------------
- layers:
------------------------------------------------------------
Name:  MyLayer



What would this WFS query look like?  I tried the following (but it did not
work):




var wfs = new OpenLayers.Layer.Vector( "MyFeatures", {
             strategies: [new OpenLayers.Strategy.BBOX()],
             protocol: new OpenLayers.Protocol.WFS({
             url: "http://localhost:8081//geoserver/wfs",
                 featureType: "MyLayer",
                 featureNS: "http://localhost:8081/MyMap"
             })
          });
var features = wfs.features;
alert( features.length );



The features always returns 0 length.  I have tried some different
permutations; but, I am not sure what the "featureNS" (feature namespace) is
supposed to be.  I mean, the workspace namespace is not right.  Am I to
assume it is supposed to be some URL for the store?  If so, what might that
be?  Also, I don't know what the "featureType" is.


The definitions for each (in the API doc) are as follows:

featureType
{Array(String) or String} The local (without prefix) feature typeName(s).


featureNS
{String} The feature namespace.   Must be set in the options at
construction.


But neither are specific/explicit enough for me to figure it out and I have
not seen a documented example of this that allows me to glean the necessary
details.


Is there something that I am supposed to do for a WMS layer that I am not
seeing?  I am using GeoServer; but there is not a WMS versus WFS
configuration for these shapefiles.  At least, I have not found anything. 
My problem lies with my ignorance on how to call WFS.


Thanks again for your help and prompt response.



-----
Up the Irons!!!
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Get-Features-from-a-WMS-Layer-tp6396039p6396948.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110523/15fdbb31/attachment.html


More information about the Users mailing list