Skip to content

qgis/qgis-js

qgis-js

QGIS core ported to WebAssembly to run it on the web platform

Version: 0.0.3 (based on QGIS 3.32.1)

qgis-js Repository | qgis-js Website

⚠️πŸ§ͺ Work in progress! Currently this project is in public beta and only does very basic things like loading a QGIS project and rendering it to an image (see Features and Limitations)

πŸŒ±πŸ‘‹ Help wanted! Please try out your QGIS projects and report issues and ideas on GitHub. We are also warmly welcoming contributions to this project (see Contributing)

About

This project provides recipes to compile QGIS core and its dependencies to WebAssembly using Emscripten, CMake and vcpkg.

qgis-js provides a JavaScript/TypeScript API to interact with QGIS, load projects and render beautiful QGIS-based maps on the web platform (see Features).

Please note that our focus is currently on making the QGIS core usable. The project does not aim to bring the full QGIS desktop application, GUI library, or Python bindings (see Limitations).

πŸ“š See the qgis-js Website or ./docs for more detailed information

Packages

Package Description npm
qgis-js The qgis-js API (which also ships the .wasm binary) qgis-js on npm
@qgis-js/ol OpenLayers sources to display qgis-js maps @qgis-js/ol on npm
@qgis-js/utils Utilities to integrate qgis-js into web applications @qgis-js/utils on npm

Getting started

Example Source code StackBlitz
πŸ“ Using the qgis-js API example docs/examples/qgis-js-example-api Open the "Using the qgis-js API" example in StackBlitz
πŸ—ΊοΈ Minimal OpenLayers example docs/examples/qgis-js-example-ol Open the "Minimal OpenLayers" example in StackBlitz

Compatibility

A modern desktop browser is needed. At the moment we only support/test Chromium-based browsers (>= 95) and Firefox (>= 100)

πŸ“š See docs/compatibility.md for more details

Features

This project is a work in progress. Currently it provides the following features:

  • QGIS core (and its dependencies) compiled to WebAssembly
    • JavaScript/TypeScript API to interact QGIS core
  • Loading of QGIS projects
  • Non-blocking rendering of QGIS maps/tiles to ImageData
  • Optional OpenLayers integration

Limitations

Compared to the native build of QGIS, there are various limitations:

  • The API surface is very limited at the moment
  • Network-based layers (e.g. WMS, WFS, WMTS, XYZ, COG, Vector Tiles) are not supported at the moment
  • No Python (PyQGIS) available
  • No Qt GUI provided
  • Some providers that need to communicate with a server using sockets will probably never work without proxies (e.g. PostgreSQL)

How to build qgis-js

πŸ’‘ NOTE: To just use qgis-js you don't need to build it yourself, you can install it from npm. See the provided Packages.

Install dependencies

Install the following system packages (on Ubuntu 22.04):

sudo apt-get install pkg-config ninja-build flex bison

Install Qt6:

  • Download the Qt Online Installer

    • You need a free Qt account to use the installer
  • Install at least the following 6.5.2 packages:

    • WebAssembly (multi-threaded)
      • Qt 5 Compatibility Module

Alternativly you can use Another Qt installer (aqt) with Python

  • Patch Qt installation
    • Run build/scripts/qt-patches.sh to patch the Qt installation
      • Set QGIS_JS_QT env var if you're not using ~/Qt/6.5.2

Install dependencies with pnpm:

npx pnpm install

This will also invoke ./qgis-js.ts -v install on "postinstall" which

  • downloads and installs emsdk in build/emdsk
  • downloads and installs vcpkg in build/vcpkg
  • boostraps vcpkg and downlaod the ports sources

see also build/scripts/install.sh for manual installation

Compile qgis-js (and its dependencies) with Emscripten

npm run compile
  • Can also be ivoked with compile:debug or compile:release, see Build types
  • Will take about 30 minutes on a modern machine to compile all the vcpkg ports during the first run... β˜•
  • see also build/scripts/compile.sh for manual compiltion

Build qgis-js packages

You want to compile with a Release build type first

npm run compile:release

After successful compilation, you can build the packages with Vite:

npm run build

see the packages listed at the beginning of this README

Development

You probably want to compile with a Dev or Debug build type first

npm run compile:dev

Start a Vite development server:

npm run dev

Open your browser at http://localhost:5173

Libraries

Library License Links
exiv2 (0.28.0)
Image metadata library and tools
GPL-2.0-or-later Website - Source code
expat (2.5.0)
XML parser library written in C
MIT Website - Source code
gdal (3.7.1)
The Geographic Data Abstraction Library for reading and writing geospatial raster and vector data
Website - Source code
geos (3.11.2)
Geometry Engine Open Source
LGPL-2.1-only Website
inih (57)
Simple .INI file parser
BSD-3-Clause Website - Source code
json-c (2022-06-26)
A JSON implementation in C
MIT Website - Source code
libgeotiff (1.7.1)
Libgeotiff is an open source library on top of libtiff for reading and writing GeoTIFF information tags.
MIT Website - Source code
libiconv (1.17)
GNU Unicode text conversion
Website
libjpeg-turbo (3.0.1)
libjpeg-turbo is a JPEG image codec that uses SIMD instructions (MMX, SSE2, NEON, AltiVec) to accelerate baseline JPEG compression and decompression on x86, x86-64, ARM, and PowerPC systems.
BSD-3-Clause Website - Source code
liblzma (5.4.4)
Compression library with an API similar to that of zlib.
Website - Source code
libspatialindex (1.9.3)
C++ implementation of R*-tree, an MVR-tree and a TPR-tree with C API.
MIT Website - Source code
libzip (1.9.2)
A library for reading, creating, and modifying zip archives.
BSD-3-Clause Website - Source code
nlohmann-json (3.11.2)
JSON for Modern C++
MIT Website - Source code
proj (9.3.0)
PROJ library for cartographic projections
MIT Website - Source code
protobuf (3.21.12)
Protocol Buffers - Google's data interchange format
BSD-3-Clause Website - Source code
qca (2.3.6)
Qt Cryptographic Architecture (QCA).
LGPL-2.1 Website - Source code
qgis (3.32.1)
QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
GPL-2.0 Website - Source code
qt6 (6.5.2)
Qt6 Application Framework Base Module. Includes Core, GUI, Widgets, Networking, SQL, Concurrent and other essential qt components.
LGPL-3.0 Website - Source code
qtkeychain (0.14.0)
(Unaffiliated with Qt) Platform-independent Qt5 API for storing passwords securely
BSD-3-Clause Website - Source code
sqlite3 (3.43.1)
SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.
blessing Website
tiff (4.6.0)
A library that supports the manipulation of TIFF image files
libtiff Website - Source code
zlib (1.3)
A compression library
Zlib Website - Source code

Build types

Dev build type

  • Optimized for fast link times during development
    • Symbols are present (e.g. meaningful stack traces)
    • Enables some Emscripten assertions
    • No DWARF debug info
  • Empty CMAKE_BUILD_TYPE in CMake

Debug build type

  • Optimized for debugging with DWARF in Chromium-based browsers
    • Includes symbols and DWARF debug info
    • Enables most Emscripten assertions
  • see docs/debugging.md on how to get started
  • Will take much longer to build than the default Dev build type
  • CMAKE_BUILD_TYPE=Debug in CMake

Release build type

  • Optimized for performance and minimal package size
    • No symbols, assertions or DWARF debug info
    • Minified JavaScript files
  • Will take much longer to build than the default Dev build type
  • CMAKE_BUILD_TYPE=Release in CMake

Contributing

Contributions welcome, see CONTRIBUTING.md for how to get started

License

GNU General Public License v2.0