Skip to content

qgis/qgis-js

qgis-js

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

Version: 0.0.5 (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 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
double-conversion (3.3.0)
Efficient binary-decimal and decimal-binary conversion routines for IEEE doubles.
Website - Source code
egl-registry (2022-09-20)
the EGL API and Extension Registry
Website - Source code
exiv2 (0.28.1)
Image metadata library and tools
GPL-2.0-or-later Website - Source code
expat (2.6.0)
XML parser library written in C
MIT Website - Source code
freetype (2.13.2)
A library to render fonts.
FTL OR GPL-2.0-or-later 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.3)
Geometry Engine Open Source
LGPL-2.1-only Website
gumbo (0.10.1)
An HTML5 parsing library in pure C99
Apache-2.0 Website - Source code
inih (57)
Simple .INI file parser
BSD-3-Clause Website - Source code
json-c (2023-08-12)
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.2)
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
libpng (1.6.40)
libpng is a library implementing an interface for reading and writing PNG (Portable Network Graphics) format files
libpng-2.0 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.10.1)
A library for reading, creating, and modifying zip archives.
BSD-3-Clause Website - Source code
litehtml (0.6.0)
litehtml is the lightweight HTML rendering engine with CSS2/CSS3 support.
BSD-3-Clause Website - Source code
nlohmann-json (3.11.3)
JSON for Modern C++
MIT Website - Source code
opengl-registry (2022-09-29)
the API and Extension registries for the OpenGL family APIs
Website - Source code
opengl (2022-12-04)
Open Graphics Library (OpenGL)[3][4][5] is a cross-language, cross-platform application programming interface (API) for rendering 2D and 3D vector graphics.
pcre2 (10.42)
Regular Expression pattern matching using the same syntax and semantics as Perl 5.
BSD-3-Clause Website - Source code
proj (9.3.1)
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.7)
Qt Cryptographic Architecture (QCA).
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
qt5compat (6.6.1)
The module contains unsupported Qt 5 APIs
Website
qtbase (6.6.1)
Qt Application Framework Base Module. Includes Core, GUI, Widgets, Networking, SQL, Concurrent and other essential qt components.
Website
qtkeychain (0.14.0)
(Unaffiliated with Qt) Platform-independent Qt5 API for storing passwords securely
BSD-3-Clause Website - Source code
qtsvg (6.6.1)
Qt SVG
Website
qttools (6.6.1)
Qt Tools
Website
sqlite3 (3.45.0)
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.1)
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