0

I would like to display my GML file but I don't understand why nothing appear in the map:

code:

import Map from 'ol/Map'
import Layer_Tile from 'ol/layer/Tile'
import source_OSM from 'ol/source/OSM'
import View from 'ol/View'
import VectorS from 'ol/source/Vector'
import VectorL from 'ol/layer/Vector'
import WFS from 'ol/format/WFS'
import GML from 'ol/format/GML32'


var map = new Map({
  layers: [
    new Layer_Tile({
      source: new source_OSM()
    })
  ],
  target: 'map',
  view: new View({
    center: [0, 0],
    zoom: 2
  })
});

const vectorSource = new VectorS({
    url: 'JeuxTestv2.gml',
    format: new WFS({
      gmlFormat: new GML({
        srsName: 'EPSG:3948'
      })
    }), 
});
var vector = new VectorL({
  source: vectorSource
});
map.addLayer(vector);
vectorSource.on('change', e => {
  if (vectorSource.getState() === 'ready') {
    map.getView().fit(vectorSource.getExtent());
  }
})

My GML file:

<?xml version="1.0" encoding="UTF-8"?>
<!---JEUX TESTS DU PCRS V2 : Données fictives-->
<PlanCorpsRueSimplifie xmlns="http://cnig.gouv.fr/pcrs" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" gml:id="SchemaPCRSv2" version="2.0" xsi:schemaLocation="http://cnig.gouv.fr/pcrs ../CNIG_PCRS_v2.0.xsd">
    <gml:boundedBy>
        <gml:Envelope srsName="EPSG:3948">
            <gml:lowerCorner>2050999.431282464 7273998.947281252</gml:lowerCorner>
            <gml:upperCorner>2051701.173832032 7274399.972199726</gml:upperCorner>
        </gml:Envelope>
    </gml:boundedBy>
  • 1
    What's definitely missing is proj4 definition of EPSG:3948 projection. – TomazicM May 7 at 7:21
  • @TomazicM How can I implement that ? proj4.defs ? Is it possible to give me an example ? – programmation1994 May 10 at 5:41
  • Besides projection definition missing with proj4.js (see example at openlayers.org/en/latest/examples/reprojection.html), there's also something wrong with GML file, I'm getting GML parsing errors in the debugger console. I'm no GML experts, so I can't help you here. – TomazicM May 10 at 9:00

Your Answer

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

Browse other questions tagged or ask your own question.