[OpenLayers-Dev] Generating a valid WFS object

Tim Schaub tschaub at opengeo.org
Fri Jul 9 17:48:43 EDT 2010


On 7/9/10 3:39 PM, Tim Schaub wrote:

... snip ...

> The featureNS corresponds to the workspace URL in GeoServer.  If you
> have a workspace named "tiger" with the "http://postgis.org" URL, then
> use that URL.  I don't think the workspace form should allow you to
> enter "http://postgis.org<http://postgis.org/>", but I could be wrong
> about that.

Ignore that bit above.  I realize now it was an email formatting issue. 
  The rest still stands.

>
> You can only make requests for features on the same origin that is
> serving up your application (see "same origin policy").  If this page is
> served up from some place like http://ubuntu:8080/mymap.html then your
> layer will work with the url you provided for your WFS.  If not, then
> you need to proxy GeoServer on the same origin that serves up your
> application (see "proxy geoserver on port 80" for details).
> Alternatively, you can set up a proxy next to your application loader
> and set OpenLayers.ProxyHost (see "openlayers faq").
>
> If your WFS is on the same origin as your application, use a relative
> URL so things will still work if you change domains.
>
> Finally, if your map is not in EPSG:32632, then you'll likely want to
> request features in your map projection.  OpenLayers can transform
> coordinates client-side, but you'd need to provide the proj4js
> definition for EPSG:32632 and your map projection.  If your OpenLayers
> map is also in EPSG:32632, then you're set.
>
> A guess at what might work for you (with some work):
>
>       layer = new OpenLayers.Layer.Vector("WFS", {
>           strategies: [new OpenLayers.Strategy.BBOX()],
>           protocol: new OpenLayers.Protocol.WFS({
>               url: "/geoserver/wfs",
>               featureType: "poi",
>               featureNS: "http://postgis.org",
>               srsName: "EPSG:32632",
>               version: "1.1.0"
>           })
>       });
>
>
> Hope that helps,
> Tim
>
> On 7/9/10 2:50 PM, Ulrik Balslev wrote:
>> Hi dev list,
>>
>> Using OpenLayers&  Geoserver for WMS seems straight forward and works
>> OK, but I cannot get it to work for WFS. I can't seem to create a valid
>> OpenLayers layer object.
>>
>> A simple HTML page like this, gives a layer ('wfslayer'), that has no
>> features (no data).
>>
>> Any hints? - Is it a security issue?
>>
>> regs.
>>
>> <html xmlns="http://www.w3.org/1999/xhtml">
>> <head>
>> <title>WFS test!</title>
>> <script src="./OpenLayers.js" type="text/javascript"></script>
>> <script>
>>           var wfslayer;
>>          OpenLayers.ProxyHost = "proxy.cgi?url=";
>>
>>           function init() {
>>
>>       wfslayer = new OpenLayers.Layer.Vector("WFS", {
>>               strategies: [new OpenLayers.Strategy.BBOX()],
>>               protocol: new OpenLayers.Protocol.WFS({
>>                   url: "http://ubuntu:8080/geoserver/wfs",
>>                   featureType: "tiger:poi",
>>                   featureNS: "http://postgis.org<http://postgis.org/>",
>>                   srsName: "EPSG:32632",
>>                   version: "1.1.0"
>>                 })
>> });
>>             }
>> </script>
>> </head>
>> <body onload="init()">
>> </body>
>> </html>
>>
>>
>>
>> _______________________________________________
>> Dev mailing list
>> Dev at openlayers.org
>> http://openlayers.org/mailman/listinfo/dev
>
>


-- 
Tim Schaub
OpenGeo - http://opengeo.org
Expert service straight from the developers.



More information about the Dev mailing list