0

On CentOS 7 I have QGIS Server and QGIS Desktop installed. In QGIS Desktop I created a project with raster and vector data and saved it in a ".qgs" file. Then I copied the file in "/var/www/html/cgi-bin/" and also copied the files "qgis_mapserv.fcgi" and "wms_metadata.xml" into this directory.

In my html-file I created a raster layer:

        var layer = new ol.layer.Image({
            source: new ol.source.ImageWMS(({
            url: 'http://localhost/cgi-bin/qgis_mapserv.fcgi',
            params: {'LAYERS': 'RasterLayerName'},
            serverType: 'qgis',
            crossOrigin: null
            }))
        });

That worked once. In an other project it didn't work. And I couldn't add a vector layer.

Is this the way to refer to QGIS layers with OpenLayers?

1 Answer 1

0

It really works with a reference to qgis_mapserv.fcgi:

    var layer = new ol.layer.Tile({
    type: 'base',
    visible: true,
    source: new ol.source.TileWMS({
        url: 'http://localhost/cgi-bin/qgis_mapserv.fcgi',
        params: {'LAYERS': 'RasterLayerName', 'TILED': true},
    })
});

Then add the layer to your map.

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.