In geoserver i have a layer in EPSG:4326. In OpenLayers i add it on map as WFS:

            markerLayer = new OpenLayers.Layer.Vector('Markers',{
        strategies: [new OpenLayers.Strategy.BBOX()],
        protocol: new OpenLayers.Protocol.WFS({
             version: "1.1.0",
            url:  "/geoserver/wfs",
            featureType: "markers",
            featureNS: "http://www.opengeospatial.net/cite",
        projection:new OpenLayers.Projection("EPSG:900913"),
        styleMap: new OpenLayers.StyleMap({
            externalGraphic: url_servlet+'img/marker.png',
            graphicWidth: 20, graphicHeight: 24, graphicYOffset: -24,
            title: '${tooltip}'
        eventListeners: {
                beforefeatureadded: function(e) {
                    e.feature.attributes.annotation =
                        window.prompt("annotation", "no comment");

My map in OL in EPSG:900913. So when i says to WFS projection=900913 i exepcted that features reproject and will show on my map. But its show somewhere outside OSM extent. And in WFS layer i see features with coords like this:

    POINT(62.01759636987174 56.767130970984326)

So how reproject wfs correctly?


I change protocol to HTTP and get gml:

            protocol:new OpenLayers.Protocol.HTTP({
            url: "/geoserver/ows?service=WFS&request=GetFeature&typeName=cite:markers&srsName=EPSG:900913&outputFormat=GML2",
            format: new OpenLayers.Format.GML()

And now i get something interesting: My layers and Google Base layer: enter image description here

Same place with OSM base layer:

enter image description here

You see that there is no more red markers. And i have only question What a hell going on?

  • google support both 4326 and 900913 projection, so it can identify which proj it is. OSM base map (not osm as a whole) supports 900913 but your data is in 4326. thats why you will get atlantic ocean.
    – neogeomat
    Commented Apr 10, 2013 at 8:46
  • @byom: Its correct but i get not ocean. OSM shows nothing even on max zoom.
    – Kliver Max
    Commented Apr 10, 2013 at 8:56
  • take out the line srsName:"EPSG:4326", which overrides the map projection in the request
    – Ian Turton
    Commented Apr 10, 2013 at 10:58

2 Answers 2


The projection of the WFS vector layer needs to be set to the projection of the data. i.e 4326 and not 900913.

OpenLayers will reproject the data on-the-fly, if the projection of the Map and the Projection of the data have been set correctly.

Please see this working sample for more details: WFS Reprojection Example

The following sample code shows how you can have a simple map with just an OSM layer, and your WFS layer. Make sure that you point the proxy to your own properly configured proxy.

var map;

function init() {
    var geographic = new OpenLayers.Projection("EPSG:4326");
    var mercator = new OpenLayers.Projection("EPSG:3857");
    OpenLayers.ProxyHost = "/cgi-bin/proxy_Open.cgi?url=";

    map = new OpenLayers.Map('map', {
        projection: mercator,
        layers: [new OpenLayers.Layer.OSM()],
        center: new OpenLayers.LonLat(21.2442, -28.464324)
        // Map uses web mercator as projection, so we have to
        // transform our coordinates
        .transform('EPSG:4326', 'EPSG:3857'),
        zoom: 10

        var wfs = new OpenLayers.Layer.Vector("Points", {
            strategies: [new OpenLayers.Strategy.BBOX()],
            protocol: new OpenLayers.Protocol.WFS({
            version: "1.0.0",
            srsName: "EPSG:4326", // this is the default projection of the data
            featurePrefix: 'za',
            url:  "http://demo.opengeo.org/geoserver/wfs",
            featureType: "za_points"
            projection: geographic // specified because it is different than the map 



you have specified the projection of layer as 900913, change it to 4326. you can define the map projection as 900913, and openlayers will reproject it.

  • I try but not help.
    – Kliver Max
    Commented Apr 10, 2013 at 8:55

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.