0

I'm trying to add from GeoServer vector layer with these 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:

<script>        
        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();
        map.addLayer(osm);          
        var bing = new OpenLayers.Layer.Bing({
            key: "AqTGBsziZHIJYYxgivLBf0hVdrAk9mWO5cQcb8Yux8sW5M8c8opEC2lZqKR1ZZXf",
            type: "Aerial",
        });
        map.addLayer(bing);
        
        var marine = new OpenLayers.Layer.Vector("marine", {
            strategies: [new OpenLayers.Strategy.Fixed()],
            protocol: new OpenLayers.Protocol.WFS({
                version: "1.1.0",
                url:"http://localhost:8080/geoserver/wfs",
                featureNS: "http://www.geoserver.org/marine",
                featureType: "marine",
                geometryName: "the_geom",
                srsName: "EPSG:900913"  
                 
            })
        });
        mapp.addLayer(marine);

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

0

1 Answer 1

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.