QGIS Server – Configuring QWC2 Web Client in Production and Displaying Custom Maps

qgis-serverqwc2

I have successfully set up a QGIS Server and can access the default world map when I go to the corresponding url.
I also set up qwc2 using the qwc2-demo-app repo and I can access the default map from myapp.com/qwc

I would like to display the map that the QGIS Server is serving from the qwc2 web client. I have tried to change the url parameter of the themes.json to the url of the QGIS Server URL but it is still displaying the default map published with the qwc2 demo app.

How do I make this web client app serve the QGIS Server map?

Best Answer

After cloning the qwc2-demo-app you need to edit the themesConfig.json file and add your-custom-url that is serving the qgis maps under:

"themes":{
        "items":[
            {
                "url":"your-custom-url",

and under:

"groups":[
            {
                "title":"Dev Tests",
                "items":[
                    {
                        "title": "Demo",
                        "url": "your-custom-url",

Determine whether the included backgroundLayers and externalLayers are relevant for your use case. Include others or remove these objects from the config altogether.

Save themesConfig.json and then run yarn run prod.

You can now point your webserver to the resulting prod directory or copy it to your preferred html root. Make sure to add a location block pointing this directory in your htaccess or nginx conf files.

Related Question