Ok, I know that this question has been asked here many times and I apologize for asking it again but I've looked all answers and I still can't fix my code to work.

I would really appreciate if someone could tell me where I'm going wrong. I'm trying to add from GeoServer vector layer with this attributes:

  • layer name:marine,
  • workspace:marine,
  • workspace url: "http://www.geoserver.org/marine"
  • epsg of layer on geoserver: 3765, epsg of map used in openlayers: 900913

This is part of my code that could help you see where I'm wrong:

        var geographic = new OpenLayers.Projection("EPSG:4326");
        var mercator = new OpenLayers.Projection("EPSG:900913");                        
        var world = new OpenLayers.Bounds(-180, -89, 180, 89).transform(
            geographic, mercator
        var center = new OpenLayers.LonLat(16.00, 44.00).transform(
            geographic, mercator
        var map = new OpenLayers.Map("map-id", {
            projection: mercator,
            displayProjection: geographic,
            units: "m",
            numZoomLevels: 16,
            maxExtent: world});
        map.addControl(new OpenLayers.Control.Permalink());
        map.addControl(new OpenLayers.Control.MousePosition());

        var osm=new OpenLayers.Layer.OSM();
        var bing = new OpenLayers.Layer.Bing({
            key: "AqTGBsziZHIJYYxgivLBf0hVdrAk9mWO5cQcb8Yux8sW5M8c8opEC2lZqKR1ZZXf",
            type: "Aerial",

        var marine = new OpenLayers.Layer.Vector("marine", {
            strategies: [new OpenLayers.Strategy.Fixed()],
            protocol: new OpenLayers.Protocol.WFS({
                version: "1.1.0",
                featureNS: "http://www.geoserver.org/marine",
                featureType: "marine",
                geometryName: "the_geom",
                srsName: "EPSG:900913"  


Somebody mentioned on one topic that if I put my HTML file to geoserver-->data_dir-->www, it could help but it didn't.

I spent more then half day trying to figure out where I wrong and I would really appreciate help. I just can't understand why is adding WFS layer such a big problem for everyone??

  • OpenLayers.Bounds(-180, -89, 180, 89) can't be converted to web mercator - there is no such extent. Can you try (-180, -85, 180, 85)?
    – BradHards
    Feb 6, 2013 at 0:03
  • Do you see any errors in FireBug? Feb 6, 2013 at 3:41
  • 2
    Most cases, when WFS requests doesn't work, are caused by browser's same origin policy and you need to set up Proxy or server your JS and WFS from same server:port. But I read you copied your html to geoserver's directory, and that didn't help. As suggested, examine traffic with FireBug. So you can see, whether your requset is made at all and gets answer; and WFS request may contain useful information (error description). Feb 6, 2013 at 7:34
  • @BradHards I don't see why is that problem because the same parameters where set before I add wfs layer and everything was working well. Beside that, the same parameters were used in opengeo tutorial example. But never mind, I changed it from 89 to 85 and still the same problem.
    – user14026
    Feb 6, 2013 at 10:26

1 Answer 1


I would do the following changes, and then test in Firefox with Firebug:

  1. Use the full version of Openlayers. The OpenLayers that comes with geoserver, is a compact version, which does not have many classes including the OpenLayers.Protocol.WFS class
  2. I would change the Bounds to (-180, -85, 180, 85) as BradHards has suggested above.
  3. Change the wfs url from: http://localhost:8080/geoserver/wfs to http://~machinename~:8080/geoserver/wfs where ~machinename~ is the host name of your computer.
  4. Put this HTML file (along with any JavaScript files) in geoserverDir/webaps/root folder. Usually the root folder does not exist and you need to create it.
  5. Go to http://~machinename~:8080/index.html (or whatever is the name of your HTML file)

Please note, that this setup is only for testing purposes, and for development and deployment I would suggest having a full featured webserver like Apache or IIS or any other.

  • Yes, I use full version of Openlayers. And about changing bounds, as I've said to bradhards, it shouldn't be a problem but I've changed it just to make myself sure and still same problem. I will try other advices you said. And I will try to test it with Firebug. I didn't use firebug before, I hope it's simple. I was writing my html in notepad++ (I know that's not the best option for writing html but I really got used to notepad++ and it was fine enough for me until now).
    – user14026
    Feb 6, 2013 at 10:29
  • Ok, now I tried all of your advices and it still doesn't work. I created root folder, set my machinename instead of localhost and all that. I typed the url in my web browser but it's still just the blank map when it opens. I don't see any features, just the title of the map and information about osm data (Data CC-By-SA by OpenStreetMap) . But no basemap or wfs. The same thing is when I try it with firebug, that's the only thing that display above my code and I can't see any errors shown (but reason for that could also be that I don't know how to use firebug because I've never worked with it).
    – user14026
    Feb 6, 2013 at 10:57
  • @njok: Explaining how to use firebug is big topic in itself, but here is a blogpost I found on how to use the net tab: softwareishard.com/blog/firebug/… This is useful to find out what requests are sent by your browser, and what response you have got. Also check the console tab, and make sure it is active. Feb 6, 2013 at 11:57
  • Ok, thank you very much Devdatta, I will try it later, I hope that will help me to detect the problem.
    – user14026
    Feb 6, 2013 at 12:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy