There are various scripts to help set up MapComplete for developing and for deployment.
This documents attempts to shed some light on these scripts.
Note: these scripts change every now and then - if the documentation here is incorrect or you run into troubles, do leave a message in the issue tracker
At its core, MapComplete is a static (!) website. There are no servers to host.
The data is fetched from Overpass/OSM/Wikidata/Wikipedia/Mapillary/... and written there directly. This means that any static file server will do to create a self-hosted version of MapComplete.
make
, python3
, g++
(Nix users may run nix-env -iA nixos.gnumake nixos.gdc nixos.python3
)
You need at least 3GB RAM available to run MapComplete, but you'll preferably have 8GB of free RAM available.
To develop and build MapComplete, you
- Make a fork and clone the repository. (We recommend a shallow clone with
git clone --filter=blob:none <repo>
) - Install
python3
if you do not have it already - On Linux:sudo apt install python3
- Install
nvm
to easily install node:wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
- Restart your terminal
- Run
nvm install
andnvm use
to install and use the correct version of node. (_Note: nvm might complain that the relevant version is not yet installed. It'll have it installed only for the current user account but not system-wide - which is fine)
- Run
npm run init
(including run, not)which …npm init
- runs
npm ci
for you - generates some additional dependencies and files
- does various housekeeping and setup. This can take a few minutes the first time as some PNGs need to be created
- runs
- Run
npm run start
to host a local testversion at http://localhost:1234/ - By default, a landing page with available themes is served. In order to load a single theme, use
layout=themename
oruserlayout=true#<layout configuration>
as Query parameter. Note that the shorter URLs (e.g.bookcases.html
,aed.html
, ...) don't exist on the development version.
The previous instructions were tested on 2023-03-09 on a Ubuntu 22.04 machine.
You need at least 3GB RAM available to run MapComplete, but you'll preferably have 8GB of free RAM available.
For Windows you can use the devcontainer, or the WSL subsystem.
To use the devcontainer in Visual Studio Code:
- Make sure you have installed the Remote - Containers extension and it's dependencies.
- Make a fork and clone the repository.
- After cloning, Visual Studio Code will ask you if you want to use the devcontainer.
- Then you can either clone it again in a volume (for better performance), or open the current folder in a container.
- By now, you should be able to run
npm run start
to host a local testversion at http://localhost:1234/index.html - By default, a landing page with available themes is served. In order to load a single theme, use
layout=themename
oruserlayout=true#<layout configuration>
as Query parameter. Note that the shorter URLs ( e.g.bookcases.html
,aed.html
, ...) don't exist on the development version.
To use the WSL in Visual Studio Code:
- Make sure you have installed the Remote - WSL extension and it's dependencies.
- Open a remote WSL window using the button in the bottom left.
- Make a fork and clone the repository.
- Install
npm
usingsudo apt install npm
. - Run
npm run init
and generate some additional dependencies and generated files. Note that it'll install the dependencies too - Run
npm run start
to host a local testversion at http://localhost:1234/index.html - By default, a landing page with available themes is served. In order to load a single theme, use
layout=themename
oruserlayout=true#<layout configuration>
as Query parameter. Note that the shorter URLs ( e.g.bookcases.html
,aed.html
, ...) don't exist on the development version.
Currently, the master branch is automatically deployed to https://mapcomplete.org/ by a GitHub action.
Every branch is automatically built (upon push) to https://pietervdvn.github.io/mc/<branchname>
by a GitHub action.
A script creates a webpage for every theme automatically, with some customizations in order to:
- to have shorter URLs
- have individual social images
- have individual web manifests
This script can be invoked with npm run prepare-deploy
If you want to deploy your fork:
npm run prepare-deploy
npm run build
- Copy the entire
dist
folder to where you host your website. Visitingindex.html
gives you the landing page, visitingyourwebsite/<theme>
should bring you to the appropriate theme.
Try removing node_modules
, package-lock.json
and .cache
.
The json-git-merger is used to quickly merge translation
files, documentation here.
This merge driver is broken and would sometimes drop new questions or duplicate them... Not a good idea!
increase-memory
: give Node.js some more RAM since this is a big (and memory intensive) project to build and runstart
: start a development servertest
: run the unit testsinit
: generate and download various assets which are needed to compilegenerate:editor-layer-index
: download the editor-layer-index-json from osmlab.github.iogenerate:images
: compile the SVGs into an assetgenerate:translations
: compile the translation file into a JavaScript filegenerate:layouts
: useindex.html
as template to create all the theme index pages. You'll want to runclean
when donegenerate:docs
: generate various documents, such as information about available metatags, information to put on the OSM wiki, ...generate:report
: download statistics from OsmCha, compile neat graphsgenerate:cache:speelplekken
: create an offline copy of all the data required for one specific (paid for) themegenerate:layeroverview
: read all the theme and layer configurations, compiles them into a single JSON.reset:layeroverview
: if something is wrong with the layer overview, create an empty onegenerate:licenses
: compile all the license info of images into a single JSONoptimize:images
: attempt to make smaller PNGs - optional to run before a deploymentgenerate
: run all the necessary generate-scriptsbuild
: actually bundle all the files into a singledist/
folderprepare-deploy
: create the layoutsdeploy:staging
,deploy:pietervdvn
,deploy:production
: deploy the latest code on various locationslint
: get depressed by the amount of warningsclean
: remove some generated files which are annoying in the repo