1

I have set up a QGIS server and I can get to the data it spits out via a WMS connection in QGIS desktop. Now I'm trying to get the same service to display in an OpenLayers 3 map.

Here's the JavaScript I'm trying to use:

var map;

function init(){
    map = new ol.Map({
        target:'map',
            renderer:'canvas',
            view: new ol.View({
            projection: 'EPSG:2966',
            center:[2809414,1031652],
            zoom:5
        })
    });

    var newLayer = new ol.layer.Image({
        source: new ol.source.ImageWMS({
            url: 'http://localhost/qgis/qgis_mapserv.fcgi.exe',
            params: {'LAYERS': 'Lateral', 'FORMAT':'image/png', 
           'VERSION': '1.3.1'}
        })
   });

    map.addLayer(newLayer);

Nothing is displayed on the page, and I'm getting a error in the JavaScript console:

TypeError: e is undefined ol.js:56

If I need to post the html let me know, but there isn't much to it.

  • Are you using ol-debug.js or the minified version? You will get more useful error messages from the former. – John Powell Dec 8 '14 at 7:25
  • It seems you solve it. What was the issue at the end? – ThomasG77 Dec 8 '14 at 16:42
  • Switching to ol-debug.js did show that it wasn't getting the projection information it needed, your post showed me how to correct that. Thanks! – HeyOverThere Dec 8 '14 at 16:47
3

It seems you do not declare any projection at the beginning of your code, whereas you are using within the view the declaration projection: 'EPSG:2966',

You should first declare

var projection = new ol.proj.Projection({
  code: 'EPSG:2966',
  units: 'ft'
});

It does not relies on Proj4js, see a previous answer to understand it purpose

You can also visit this official example so see how Proj4js works.

Edit 1:

Where does the 'VERSION': '1.3.1' come? It means that it exists a WMS version 1.3.1 whereas it does not (see the http://www.opengeospatial.org/standards/wms)

You should use 'VERSION': '1.3.0'. The VERSION parameter manage the x, y axis order.

  • Nope, same result, though I'm sure that this solves the next problem I would have had getting this running. Also, EPSG:2966 is in ft, I assume units: 'ft' is correct, or no? – HeyOverThere Dec 8 '14 at 4:01
  • Yup, units should be whatever your projection units are? – John Powell Dec 8 '14 at 7:25
  • Corrected in my answer. – ThomasG77 Dec 8 '14 at 8:54
  • Your WMS version is wrong, see edit in my answer – ThomasG77 Dec 8 '14 at 9:02
  • The projection fix got the map tools to load, but not my map. That's a separate issue that I'll work on and start a new question if needed. Thanks for your help! I fixed the 1.3.0 as well, 1.3.1 was the version of the Capabilities report QGIS server puts out, the WMS service is still a 1.3.0. – HeyOverThere Dec 8 '14 at 16:46

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.