title: Load GML layer with Openlayers 3
body: <p>I'm trying to load a <code>GML</code> file into a vector layer and plot it on a map. For some reason the features do not get shown on the map although they get parsed and added to the vector layer.</p>
  
  <p>I tried it with a <code>GML</code> file coming from <code>Geoserver</code> (making minor modifications to  the source code) and <code>openlayers 3</code> seems to have no problem digesting it.</p>
  
  <p>Am I missing something, or is there something with the <code>GML</code> parser not supporting custom files?</p>
  
  <p>Code:</p>
  
  <pre><code>(function() {} (
          'use strict';
  
          var map = new ol.Map({
              target: 'map',
              layers: [
                  new ol.layer.Tile({
                      source: new ol.source.OSM()
                  })
              ],
              view: new ol.View({
                  center: ol.proj.transform([0, 30], 'EPSG:4326', 'EPSG:3857'),
                  zoom: 2
              })
          });
  
          var xmlhttp = new XMLHttpRequest();
  
          xmlhttp.open("GET", "/echo/xml/", 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:4326',
                  dataProjection: 'EPSG:3857'
              });
  
              var vector = new ol.layer.Vector({
                  source: new ol.source.Vector({
                      format: format
                  })
              });
  
              // Add features to the layer's source
              vector.getSource().addFeatures(features);
  
              map.addLayer(vector);
          };
          xmlhttp.send();
  ));
  </code></pre>
  
  <p>The original <code>GML</code> file is available at <a href="http://www.ioc-sealevelmonitoring.org/service.php?server=gml&amp;show=active&amp;showgauges=t" rel="nofollow">IOC stations GML</a>. I made a copy of it locally to avoid <code>CORS</code>.</p>