I've installed QGIS server and it works fine. I've put qgs file in the server folder dir and using "Add WMS layer" from QGIS I manage to view the qgs file.

This is how I use GetCapabilities for example: http://www.localhost.com/qgis/qgis_mapserv.fcgi.exe?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities&map=D:/OSGeo4W/apps/qgis/bin/MyLondon.qgs&

Now my problem is that in all OpenLayers WMS examples, adding WMS layer looks like this:

layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
          {layers: 'basic'}

How do I convert my WMS to this format? Where in the URL I set the project name and where the layer name?

  • The URL should include the map=value& parameter – nmtoken Sep 20 '18 at 11:10

I've posted a solution that works for me on http://underdark.wordpress.com/2012/03/30/qgis-server-on-ubuntu-step-by-step/. Adjusted to your information, it would be something like:

wms = new OpenLayers.Layer.WMS(
'london_basic', "http://www.localhost.com/qgis/qgis_mapserv.fcgi.exi",
    layers: 'basic', 
    format: 'image/png',
    map: 'D:/OSGeo4W/apps/qgis/bin/MyLondon.qgs',
    buffer: 1, 
    isBaseLayer: true, 
    graphicZIndex: 0, 
| improve this answer | |
  • Thank you , is there a way to configure my qgis server to be more URL friendly like the example I've posted ? – Alophind Jan 27 '13 at 17:31
  • Anita , in your Vienna example u didn't write use map name , how come ? – Alophind Jan 27 '13 at 17:34
  • I had only one project in the same folder, so it automatically used that one. Sorry, but what do you mean by URL friendly? – underdark Jan 27 '13 at 20:50
  • I meant be able to use url vmap0.tiles.osgeo.org/wms/vmap0 instead of the entire QGIS settings – Alophind Jan 28 '13 at 8:17
  • Btw , this still doesnt work for me. I see white rectangle while QGIS does show me the 3 layers inside my project (from the WMS) – Alophind Jan 28 '13 at 8:51

The map parameter is part of the service endpoint URL, so the syntax would be like:

layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
    {layers: 'basic'}

To convert to a more friendly endpoint URL like http://localhost/qgis/qgis_mapserv.fcgi.exe? add a SetEnvIf parameter to your Apache config, something like:

SetEnvIf Request_URI "/qgis/qgis_mapserv.fcgi.exe" MS_MAPFILE=D:/OSGeo4W/apps/qgis/bin/MyLondon.qgs
| improve this answer | |
  • Interesting. I am experiencing similar problems as the OP. Will try this later. – umbe1987 Nov 12 '18 at 11:33

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.