I have requested vector layer through WFS GetFeature from GeoServer in GML2 format but when displaying WFS layer its showing on different place. same layer i have requested in format Geojson its showing on correct location. My vector layer is in EPSG:4326 projection and when displaying in Geojson format its correctly displaying but in GML2 format its showing on wrong place which is on EPSG:900913 location. As i understand WFS layer is in EPSG:4326 projection in Geoserver but whenever layer requested in GML2 format its converting or changing projection to EPSG 900913 and showing on wrong place. My question is how to display GML2 layer in correct position(EPSG4326) and why GML2 layer automatically changing projection? or if GML2 showing on EPSG900913 what is the code i can apply so it will be in EPSG4326 ? I am giving here my code also:https://jsfiddle.net/seema30/dww9gxcy/ please give the suggestions.

  • Is your map in 900913?
    – Ian Turton
    May 6, 2017 at 16:14
  • No it's in EPSG:4326 May 6, 2017 at 17:01
  • Please add a minimum working example and the actual request and response sent to and from the server
    – Ian Turton
    May 6, 2017 at 17:03
  • It's working example just we have to zoom in too much in the Ghana south side ocean. it will show as a dark point like area but whenever we will zoom too much on that area map will appear. Actually its India boundary layer it has to be display on correct OSM map. When we request in GeoJson format it works fine..only GML format has a problem May 6, 2017 at 17:18
  • Please edit the question to save people having to wade through all of the code.
    – Ian Turton
    May 6, 2017 at 17:33

1 Answer 1


I solved the problem. Its projection problem i solved it using following code

  var xmlhttp = new XMLHttpRequest();
    xmlhttp.open("GET", "http://localhost:8088/geoserver/mapper/ows?service=WFS&version=1.1.0&request=GetFeature&typeName=mapper:ind_adm1&maxFeatures=50&outputFormat=text%2Fxml%3B%20subtype%3Dgml%2F2.1.2", true);
    xmlhttp.onload = function () {
        var format = new ol.format.GML2();

        var xmlDoc = xmlhttp.responseXML;

        // Read and parse all features in XML document
        var features = format.readFeatures(xmlDoc, {
            featureProjection: 'EPSG:3857',
            dataProjection: 'EPSG:4326'

        var vector = new ol.layer.Vector({
            source: new ol.source.Vector({
                format: format

        // Add features to the layer's source


Your Answer

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

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