2021-02-23 19:29:54 +01:00
|
|
|
Making your own theme
|
|
|
|
=====================
|
|
|
|
|
2021-09-09 00:05:51 +02:00
|
|
|
In MapComplete, it is relatively simple to make your own theme. This guide will give some information on how you can do
|
|
|
|
this.
|
2021-02-23 19:29:54 +01:00
|
|
|
|
|
|
|
Requirements
|
|
|
|
------------
|
|
|
|
|
|
|
|
Before you start, you should have the following qualifications:
|
|
|
|
|
|
|
|
- You are a longtime contributor and do know the OpenStreetMap tagging scheme very well.
|
|
|
|
- You are not afraid of editing a .JSON-file
|
|
|
|
- You're theme will add well-understood tags (aka: the tags have a wiki page, are not controversial and are objective)
|
2021-09-09 00:05:51 +02:00
|
|
|
- You are in contact with your local OpenStreetMap community and do know some other members to discuss tagging and to
|
|
|
|
help testing
|
2021-02-23 19:29:54 +01:00
|
|
|
|
2021-09-09 00:05:51 +02:00
|
|
|
If you do not have those qualifications, reach out to the MapComplete community channel
|
|
|
|
on [Telegram](https://t.me/MapComplete)
|
2021-07-11 12:25:16 +02:00
|
|
|
or [Matrix](https://app.element.io/#/room/#MapComplete:matrix.org).
|
2021-02-23 19:29:54 +01:00
|
|
|
|
|
|
|
The custom theme generator
|
|
|
|
--------------------------
|
|
|
|
|
2021-09-09 00:05:51 +02:00
|
|
|
The custom theme generator is a special page of MapComplete, where one can create their own theme. It makes it easier to
|
|
|
|
get started.
|
2021-02-23 19:29:54 +01:00
|
|
|
|
2021-09-09 00:05:51 +02:00
|
|
|
However, the custom theme generator is extremely buggy and built before some updates. This means that some features
|
|
|
|
are _not_ available through the custom theme generator. The custom theme generator is good to get the basics of the
|
|
|
|
theme set up, but you will have to edit the raw JSON-file anyway afterwards.
|
2021-02-23 19:29:54 +01:00
|
|
|
|
2021-02-23 19:34:34 +01:00
|
|
|
[A quick tutorial for the custom theme generator can be found here](https://www.youtube.com/watch?v=nVbFrNVPxPw).
|
2021-02-23 19:29:54 +01:00
|
|
|
|
|
|
|
Loading your theme
|
|
|
|
------------------
|
|
|
|
|
|
|
|
If you have your .json file, there are three ways to distribute your theme:
|
|
|
|
|
2021-09-09 00:05:51 +02:00
|
|
|
- Take the entire JSON-file and [base64](https://www.base64encode.org/) encode it. Then open up the
|
|
|
|
url `https://mapcomplete.osm.be?userlayout=true#<base64-encoded-json-here>`. Yes, this URL will be huge; and updates
|
|
|
|
are difficult to distribute as you have to send a new URL to everyone. This is however excellent to have a 'quick and
|
|
|
|
dirty' test version up and running as these links can be generated from the customThemeGenerator and can be quickly
|
|
|
|
shared with a few other contributors.
|
|
|
|
- Host the JSON file on a publicly accessible webserver (e.g. github) and open
|
|
|
|
up `https://mapcomplete.osm.be?userlayout=<url-to-the-raw.json>`
|
2021-02-23 19:29:54 +01:00
|
|
|
- Ask to have your theme included into the official MapComplete - requirements below
|
|
|
|
|
|
|
|
### Getting your theme included into the official mapcomplete
|
|
|
|
|
2021-09-09 00:05:51 +02:00
|
|
|
Did you make an awesome theme that you want to share with the OpenStreetMap community? Have it included in the main
|
|
|
|
application, which makes it more discoverable.
|
2021-02-23 19:29:54 +01:00
|
|
|
|
|
|
|
Your theme has to be:
|
|
|
|
|
2021-09-09 00:05:51 +02:00
|
|
|
0) Make sure the theme has an English version. This makes it easier for me to understand what is going on. The more
|
|
|
|
other languages, the better of course!
|
2021-02-23 19:29:54 +01:00
|
|
|
1) Make sure your theme has good tagging
|
|
|
|
3) Make sure there are somewhat decent icons. Note that there is _no_ styleguide at the moment though.
|
|
|
|
|
2021-09-09 00:05:51 +02:00
|
|
|
The preferred way to add your theme is via a Pull Request. A Pull Request is less work for the maintainer (which makes
|
|
|
|
it really easy and for me to add it) and your name will be included in the git history (so you'll be listed as
|
|
|
|
contributor). If that is not possible, send the .Json-file and assets, e.g. as a zip in an issue, per email, ...
|
2021-02-23 19:29:54 +01:00
|
|
|
|
|
|
|
*Via a pull request:*
|
|
|
|
|
|
|
|
1) Fork this repository
|
|
|
|
2) Go to `assets/themes` and create a new directory `yourtheme`
|
2021-09-09 00:05:51 +02:00
|
|
|
3) Create a new file `yourtheme.json`, paste the theme configuration in there. You can find your theme configuration in
|
|
|
|
the customThemeBuilder (the tab with the *Floppy disk* icon)
|
|
|
|
4) Copy all the images into this new directory. **No external sources are allowed!** External image sources leak privacy
|
|
|
|
or can break.
|
2021-04-10 13:41:45 +02:00
|
|
|
- Make sure the license is suitable, preferable a Creative Commons license or CC0-license.
|
|
|
|
- If an SVG version is available, use the SVG version
|
2021-09-09 00:05:51 +02:00
|
|
|
- Make sure all the links in `yourtheme.json` are updated. You can use `./assets/themes/yourtheme/yourimage.svg`
|
|
|
|
instead of the HTML link
|
|
|
|
- Create a file `license_info.json` in the theme directory, which contains metadata on every artwork source
|
|
|
|
5) Add your theme to the code base: add it into "assets/themes" and make sure all the images are there too. Running '
|
|
|
|
ts-node scripts/fixTheme <path to your theme>' will help downloading the images and attempts to get the licenses if
|
|
|
|
on wikimedia.
|
|
|
|
6) Add some finishing touches, such as a social image.
|
|
|
|
See [this blog post](https://www.h3xed.com/web-and-internet/how-to-use-og-image-meta-tag-facebook-reddit) for some
|
|
|
|
hints
|
|
|
|
7) Test your theme: run the project as described in [development_deployment](Development_deployment.md)
|
|
|
|
8) Happy with your theme? Time to open a Pull Request!
|
|
|
|
9) Thanks a lot for improving MapComplete!
|
|
|
|
|
|
|
|
The .JSON-format
|
|
|
|
----------------
|
2021-02-23 19:29:54 +01:00
|
|
|
|
2021-09-09 00:05:51 +02:00
|
|
|
There are three important levels in the .JSON-file:
|
2021-02-23 19:29:54 +01:00
|
|
|
|
2021-09-09 00:05:51 +02:00
|
|
|
- The toplevel describes the metadata of the entire theme. It contains the `title`, `description`, `icon`... of the
|
|
|
|
theme. The most important object is `layers`, which is a list of objects describing layers.
|
|
|
|
- A `layer` describes a layer. It contains the `name`, `icon`, `tags of objects to download from overpass`, and
|
|
|
|
especially the `icon` and a way to ask dynamically render tags and ask questions. A lot of those fields (`icon`
|
|
|
|
, `title`, ...) are actually a `TagRendering`
|
|
|
|
- A `TagRendering` is an object describing a relationship between what should be shown on screen and the OSM-tagging. It
|
|
|
|
works in two ways: if the correct tag is known, the appropriate text will be shown. If the tag is missing (and a
|
|
|
|
question is defined), the question will be shown.
|
2021-02-23 19:29:54 +01:00
|
|
|
|
|
|
|
Every field is documented in the source code itself - you can find them here:
|
|
|
|
|
2021-08-07 23:13:46 +02:00
|
|
|
- [The top level `LayoutConfig`](https://github.com/pietervdvn/MapComplete/blob/master/Models/ThemeConfig/Json/LayoutConfigJson.ts)
|
|
|
|
- [A layer object `LayerConfig`](https://github.com/pietervdvn/MapComplete/blob/master/Models/ThemeConfig/Json/LayerConfigJson.ts)
|
|
|
|
- [The `TagRendering`](https://github.com/pietervdvn/MapComplete/blob/master/Models/ThemeConfig/Json/TagRenderingConfigJson.ts)
|
2021-05-11 10:08:51 +02:00
|
|
|
- At last, the exact semantics of tags is documented [here](Tags_format.md)
|
2021-02-23 19:29:54 +01:00
|
|
|
|
2021-03-22 02:48:01 +01:00
|
|
|
### MetaTags
|
|
|
|
|
2021-09-09 00:05:51 +02:00
|
|
|
There are few tags available that are calculated for convenience - e.g. the country an object is located
|
|
|
|
at. [An overview of all these metatags is available here](Docs/CalculatedTags.md)
|
2021-03-22 02:48:01 +01:00
|
|
|
|
2021-09-09 00:05:51 +02:00
|
|
|
Some hints
|
2021-04-03 21:33:11 +02:00
|
|
|
------------
|
|
|
|
|
|
|
|
### Everything is HTML
|
|
|
|
|
2021-09-09 00:05:51 +02:00
|
|
|
All the texts are actually *HTML*-snippets, so you can use `<b>` to add bold, or `<img src=...>` to add images to
|
|
|
|
mappings or tagrenderings.
|
2021-04-03 21:33:11 +02:00
|
|
|
|
2021-09-09 00:05:51 +02:00
|
|
|
Some remarks:
|
2021-04-03 21:33:11 +02:00
|
|
|
|
2021-09-09 00:05:51 +02:00
|
|
|
- links are disabled when answering a question (e.g. a link in a mapping) as it should trigger the answer - not trigger
|
|
|
|
to open the link.
|
|
|
|
- If you include images, e.g. to clarify a type, make sure these are _icons_ or _diagrams_ - not actual pictures! If
|
|
|
|
users see a picture, they think it is a picture of _that actual object_, not a type to clarify the type. An icon is
|
|
|
|
however perceived as something more abstract.
|
2021-03-22 02:48:01 +01:00
|
|
|
|
2021-09-09 00:05:51 +02:00
|
|
|
Some pitfalls
|
2021-03-22 02:48:01 +01:00
|
|
|
---------------
|
2021-02-23 19:29:54 +01:00
|
|
|
|
|
|
|
### Not publishing
|
|
|
|
|
2021-09-09 00:05:51 +02:00
|
|
|
Not publishing because 'it is not good enough'. _Share your theme, even if it is still not great, let the community help
|
|
|
|
it improve_
|
2021-02-23 19:29:54 +01:00
|
|
|
|
|
|
|
### Thinking in terms of a question
|
|
|
|
|
2021-09-09 00:05:51 +02:00
|
|
|
Making a tagrendering as if it were a question only. If you have a question such as: _Does this bench have a backrest?_,
|
|
|
|
it is very tempting to have as options _yes_ for `backrest=yes` and _no_ for `backrest=no`. However, when this data is
|
|
|
|
known, it will simply show a lone _yes_ or _no_ which is very unclear.
|
2021-02-23 19:29:54 +01:00
|
|
|
|
2021-09-09 00:05:51 +02:00
|
|
|
The correct way to handle this is to use _This bench does have a backrest_ and _This bench does not have a backrest_ as
|
|
|
|
answers.
|
2021-02-23 19:29:54 +01:00
|
|
|
|
2021-09-09 00:05:51 +02:00
|
|
|
One has to think first in terms of _what is shown to the user if it is known_, only then in terms of _what is the
|
|
|
|
question I want to ask_
|
2021-02-23 19:29:54 +01:00
|
|
|
|
2021-03-24 01:56:56 +01:00
|
|
|
### Forgetting the casual/noob mapper
|
|
|
|
|
2021-09-09 00:05:51 +02:00
|
|
|
MapComplete is in the first place a tool to help *non-technical* people visualize their interest and contribute to it.
|
|
|
|
In order to maximize contribution:
|
2021-03-24 01:56:56 +01:00
|
|
|
|
|
|
|
1. Use simple language. Avoid difficult words and explain jargon
|
2021-09-09 00:05:51 +02:00
|
|
|
2. Put the simple questions first and the difficult ones on the back. The contributor can then stop at a difficult point
|
|
|
|
and go to the next POI
|
2021-03-24 01:56:56 +01:00
|
|
|
3. Use symbols and images, also in the mappings on questions
|
2021-09-09 00:05:51 +02:00
|
|
|
4. Make sure the icons (on the map and in the questions) are big enough, clear enough and contrast enough with the
|
|
|
|
background map
|
2021-03-24 01:56:56 +01:00
|
|
|
|
2021-02-23 19:34:34 +01:00
|
|
|
### Using layers to distinguish on attributes
|
|
|
|
|
2021-09-09 00:05:51 +02:00
|
|
|
One layer should portray one kind of physical object, e.g. "benches" or "restaurants". It should contain all of them,
|
|
|
|
disregarding other properties.
|
2021-02-23 19:34:34 +01:00
|
|
|
|
2021-09-09 00:05:51 +02:00
|
|
|
One should not make one layer for benches with a backrest and one layer for benches without. This is confusing for users
|
|
|
|
and poses problems: what if the backrest status is unknown? What if it is some weird value? Also, it isn't possible to '
|
|
|
|
move' an attribute to another layer.
|
2021-02-23 19:34:34 +01:00
|
|
|
|
|
|
|
Instead, make one layer for one kind of object and change the icon based on attributes.
|
|
|
|
|
2021-02-23 19:29:54 +01:00
|
|
|
### Using layers as filters
|
|
|
|
|
|
|
|
Using layers as filters - this doesn't work!
|
|
|
|
|
2021-09-09 00:05:51 +02:00
|
|
|
_All_ data is downloaded in one go and cached locally first. The layer selection (bottom left of the live app) then
|
|
|
|
selects _anything_ that matches the criteria. This match is then passed of to the rendering layer, which selects the
|
|
|
|
layer independently. This means that a feature can show up, even if it's layer is unselected!
|
2021-02-23 19:29:54 +01:00
|
|
|
|
2021-09-09 00:05:51 +02:00
|
|
|
For example, in the [cyclofix-theme](https://mapcomplete.osm.org/cyclofix), there is the layer with _bike-wash_ for do
|
|
|
|
it yourself bikecleaning - points marked with `service:bicycle:cleaning`. However, a bicycle repair shop can offer this
|
|
|
|
service too!
|
2021-02-23 19:29:54 +01:00
|
|
|
|
2021-09-09 00:05:51 +02:00
|
|
|
If all the layers are deselected except the bike wash layer, a shop having this tag will still match and will still show
|
|
|
|
up as shop.
|
2021-02-23 19:29:54 +01:00
|
|
|
|
2021-04-06 18:14:37 +02:00
|
|
|
### Not reading the .JSON-specs
|
2021-02-23 19:29:54 +01:00
|
|
|
|
2021-09-09 00:05:51 +02:00
|
|
|
There are a few advanced features to do fancy stuff available, which are documented only in the spec above - for
|
|
|
|
example, reusing background images and substituting the colours or HTML-rendering. If you need advanced stuff, read it
|
|
|
|
through!
|