[OpenLayers-Users] Problem with WFS

Pedro Baracho pedropbaracho at gmail.com
Wed Nov 18 08:05:15 EST 2009


you will need to include proj4js to transform between projections if you are
not working with EPSG:4326 or EPSG:900913

See: http://trac.openlayers.org/wiki/Documentation/Dev/ for more info.

Also. On your map options you have:
projection: "ESPG:32639"

it should be:
projection: new OpenLayers.Projection("EPSG:32639")

And I would recommend you also add projection to your layer options. It is
not necessary in this case, because it seems your map and your wfs layer are
in the same projection, but it is a good practice imho.

wfs = new OpenLayers.Layer.WFS("WFS",
                               "http://localhost:8080/geoserver/wfs", {
                                       typename :
"naji:TBL_GIS_FEATURE_POINT",
                                       maxfeatures : 1000,
                                       format : OpenLayers.Format.GML.v2
                               },
                               {projection: new
OpenLayers.Projection("EPSG:32639")});


On Wed, Nov 18, 2009 at 5:31 AM, maimaj <maimaj at gmail.com> wrote:

>
>
> Thanks for your help in the first step. You've been right, the problem was
> with projection. It's resolved but the WFS features do not show up.
>
> Before you mentioned that it might be a projection problem, I copied the
> request string (obtained by getFullRequestString function of WFS class) in
> the address bar and I received a GML2 file with some features. However,
> that
> request string doesn't include the BBOX parameter.
>
> I took your advice and fixed the SRS settings on the server and client.
> When
> I copy the request string (obtained from the log file of the Geoserver
> which
> has the BBOX parameter in it) to the address bar, the returned GML2 file
> contains only those features which are in the BBOX. Before fixing the
> projection problem, this file doesn't have any feature member (an almost
> empty GML2 file).
>
> As I mentioned before, I cannot see the features on the screen yet. The SRS
> settings on the server for this layer are as follows:
>  native srs: EPSG:32639
>  declared srs: EPSG:32639
>  srs handling: keep native
>
> And my script is the following:
>
> var map, layer, wfs;
>        function init() {
>                var bounds = new OpenLayers.Bounds(431834.067, 3887548.528,
> 684784.466,
>                                4002241.703);
>                var options = {
>                        maxExtent : bounds,
>                        maxResolution : 859.9516562499998,
>                        projection : "EPSG:32639"
>                };
>
>                map = new OpenLayers.Map('map', options);
>
>                layer = new OpenLayers.Layer.WMS("OpenLayers WMS",
>                                "http://localhost:8080/geoserver/wms", {
>                                        layers : 'naji:TBL_GIS_ARC'
>                                });
>                wfs = new OpenLayers.Layer.WFS("WFS",
>                                "http://localhost:8080/geoserver/wfs", {
>                                        typename :
> "naji:TBL_GIS_FEATURE_POINT",
>                                        maxfeatures : 1000,
>                                        format : OpenLayers.Format.GML.v2
>                                });
>                wfs.isBaseLayer = true;
>
>                map.addLayer(layer);
>                map.addLayer(wfs);
>
>                map.addControl(new OpenLayers.Control.LayerSwitcher());
>                map.zoomToExtent(bounds);
>        }
>
> Last point: I am using the "full" OL instance and the Geoserver is on the
> same machine where the above script is hosted.
>
> I am completely stuck at this point, and would appreciate any help.
>
> Thanks,
> Majid
>
>
>
> Pedro Baracho wrote:
> >
> > Could you please copy your code so I can take look?
> >
> > As I understand, WFS problems are usually related to:
> >
> > 1- Proxy and Cross Domain Requests
> > 2- Projections
> > 3- Incorrect OL instancing
> >
> > As you stated on your email, you are getting correct responses so my
> guess
> > is that you got a problem with Projections.
> >
> > On Tue, Nov 17, 2009 at 9:18 AM, maimaj <maimaj at gmail.com> wrote:
> >
> >>
> >> Hi all,
> >>
> >> I have a WMS layer as my base layer and also a WFS layer on top of it.
> >> OpenLayers renders the WMS layer perfectly, but the WFS layer doesn't
> >> show
> >> up. I am pretty sure that the OpenLayers is sending an appropriate
> >> request
> >> to the server (Geoserver) and the server is also responding properly,
> >> since:
> >>
> >>  1. Geoserver is on the same server where my own application (which
> hosts
> >> the OpenLayers.js) is. So
> >>      there's no need for the proxy.
> >>  2. Geoserver console logs show that it has received the request
> >> properly.
> >>  3. When I copy the the request string in the address bar of my web
> >> browser, I get the gml2 file from the
> >>      server (I also tested the server with uDig as the client, and it
> can
> >> render the features properly through
> >>      WFS service provided by Geoserver).
> >>
> >> Could you please help me on this issue and tell me what might be the
> >> cause
> >> of this problem? I have copied the init function from the WFS example
> >> available in the examples directory of OpenLayers 2.8 and added my own
> >> WMS
> >> layer, removed the proxy setting, and changed the WFS setting.
> >>
> >> Thanks in advance,
> >> Majid
> >>
> >> --
> >> View this message in context:
> >> http://n2.nabble.com/Problem-with-WFS-tp4017977p4017977.html
> >> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> >> _______________________________________________
> >> Users mailing list
> >> Users at openlayers.org
> >> http://openlayers.org/mailman/listinfo/users
> >>
> >
> > _______________________________________________
> > Users mailing list
> > Users at openlayers.org
> > http://openlayers.org/mailman/listinfo/users
> >
> >
>
> --
> View this message in context:
> http://n2.nabble.com/Problem-with-WFS-tp4017977p4023822.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20091118/95576e20/attachment.html


More information about the Users mailing list