Skip to content

Latest commit

Β 

History

History
102 lines (77 loc) Β· 5.16 KB

PUBLISH.md

File metadata and controls

102 lines (77 loc) Β· 5.16 KB

Publish your own QGIS project to your online Lizmap

πŸ‡«πŸ‡· Lire ceci en franΓ§ais

This guide is for the one-click GitHub Codespaces test instance. It explains how to author a QGIS project on your computer and publish it to your online Lizmap, including the case where your data lives in the bundled PostGIS database.

Your Codespace ships with an empty My projects repository ready to receive your project.

Prerequisites (on your computer)

  • QGIS Desktop with the Lizmap plugin installed.

  • VS Code Desktop (free). Once your Codespace is open in the browser, click Open in VS Code Desktop (top-left menu, or the green "Code" button on the repo). Sign in with your GitHub account when prompted β€” no separate password, no command line.

    Prefer the terminal? Everything below (uploading files, reaching PostGIS) also works with the GitHub CLI (gh) instead of VS Code Desktop β€” see the tips at the end of each step.

Step 1 β€” Make your data reachable by the server

Option A β€” file-based data (simplest)

If your layers are in a GeoPackage (or Shapefile…), just keep the data file in the same folder as your .qgs and use relative paths in QGIS. Nothing else to do β€” QGIS Server reads the file directly. Skip to step 2.

Option B β€” data in PostGIS

The stack already runs a PostGIS database; QGIS Server reads it through the pg_service named lizmap_local. The trick is to use that same service name on your desktop, so the exact same .qgs works on your machine and on the server with no edit.

  1. Open a tunnel to the Codespace database. In VS Code Desktop, open the Ports tab (bottom panel) β†’ Forward a Port β†’ type 8093 β†’ Enter. PostGIS is now reachable at localhost:8093 on your machine β€” no popup, no extra install, it just works because VS Code Desktop tunnels ports to your real localhost.

    πŸ’‘ Raw database connections only work through a desktop tool (VS Code Desktop above, or gh codespace ports forward 8093:8093 in a terminal β€” the format is <remote-port>:<local-port>, so both sides must be 8093 to match the pg_service.conf below) β€” the public https://...app.github.dev port URL only proxies HTTP(S) and cannot carry the Postgres protocol.

  2. Declare the lizmap_local service on your computer. Add this to your pg_service file (~/.pg_service.conf on Linux/macOS, %APPDATA%\postgresql\.pg_service.conf on Windows):

    [lizmap_local]
    host=localhost
    port=8093
    dbname=lizmap
    user=lizmap
    password=lizmap1234!
  3. In QGIS β†’ Data Source Manager β†’ PostgreSQL β†’ New, set Service = lizmap_local (leave Host/Port empty) and Test Connection. Using the Service field is what makes QGIS write service='lizmap_local' into the project instead of a hard-coded host β€” essential for the project to resolve on the server.

  4. Load your data into the database (schema lizmap, or create your own). For example with QGIS DB Manager (Import layer), or from a terminal:

    ogr2ogr -f PostgreSQL "PG:service=lizmap_local" my_data.gpkg -lco SCHEMA=lizmap
  5. Build your map in QGIS from those PostGIS layers. Double-check (layer β†’ Properties β†’ Source) that the datasource starts with service='lizmap_local'.

Step 2 β€” Configure the map with the Lizmap plugin

In QGIS, open the Lizmap plugin, configure your map (base layers, popups, tools…), and click Save. It writes a myproject.qgs.cfg file next to your myproject.qgs.

Step 3 β€” Send the project to your Codespace

Copy the project files (and any GeoPackage / data files if you used Option A) into the My projects repository folder of the Codespace: lizmap/instances/myprojects/.

In VS Code Desktop (or the browser editor), open the Explorer, find that folder, and either drag-and-drop your files onto it, or right-click it β†’ Upload... and pick the files. No extra tool needed.

πŸ’‘ Terminal alternative: gh codespace cp ./myproject.qgs ./myproject.qgs.cfg 'remote:/workspaces/lizmap-docker-compose/lizmap/instances/myprojects/'

Step 4 β€” Open it

Go to your Lizmap URL β€” the My projects repository now lists myproject. πŸŽ‰


Notes & troubleshooting

  • Project not listed / "repository path" error: the file must be directly under lizmap/instances/myprojects/ and named *.qgs with its *.qgs.cfg beside it.
  • Layers fail to load on the server but work locally: the datasource is probably hard-coded to localhost:8093 instead of service='lizmap_local'. Re-add the PostGIS connection using the Service field (step 1B.3) and re-save the project.
  • Visibility: My projects is viewable by anonymous visitors by default (like the demos), so you can share the map link. Change it in Admin β†’ Maps if you prefer it private.
  • Lifetime: everything (files and PostGIS data) lives inside your Codespace and is removed when the Codespace is deleted. This instance is meant for evaluation, not production.