Project

General

Profile

Mapbox » History » Version 7

Philippe May, 15/07/2019 14:59

1 1 Philippe May
h1. Mapbox
2 1 Philippe May
3 1 Philippe May
Gisaf uses mapbox-gl for rendering online maps.
4 1 Philippe May
5 4 Philippe May
h2. Base maps
6 4 Philippe May
7 4 Philippe May
Mapbox doesn't have the concept of "base map". Instead, Mapbox maps are defined with a _style_ (that we call the _base style_).
8 4 Philippe May
A mapbox style contains different layers, which can be vector based (eg. labels, roads, areas) or raster (eg. satellite). 
9 4 Philippe May
10 4 Philippe May
Gisaf adds layers (in GeoJSON format) at the top the base style.
11 4 Philippe May
12 5 Philippe May
Gisaf allows to pick a base style for the map, though a menu. The options for the base styles are stored in the database (table @map_base_style@), and editable through the admin interface. The definition of the style itself is in _json_ format, and can be created with online tools like "Maputnik":https://maputnik.github.io/editor ("MapboxStudio":https://www.mapbox.com/editor/ is also an alternative, but it's heavily linked to their business ecosystem).
13 4 Philippe May
14 1 Philippe May
15 2 Philippe May
h2. Setting styles for the layers (models)
16 1 Philippe May
17 1 Philippe May
There are 2 places where mapbox styles live, depending on the type of layer.
18 1 Philippe May
19 1 Philippe May
h3. Custom models
20 1 Philippe May
21 1 Philippe May
In the @qml@ table, define the style in the column @mapbox-paint@ corresponding to the type in the column @model_name@.
22 1 Philippe May
23 1 Philippe May
h3. Models from categories
24 1 Philippe May
25 1 Philippe May
In the @category@ table, these columns used for styling:
26 1 Philippe May
27 1 Philippe May
* @mapbox_type_custom@: the mapbox type can be overridden, eg. @fill-extrusion@ for polygons (no other known useful cases)
28 1 Philippe May
29 1 Philippe May
* @mapbox_paint@: the mapbox paint style
30 1 Philippe May
31 1 Philippe May
* @mapbox_layout@: the mapbox layout (usually not used)
32 1 Philippe May
33 1 Philippe May
34 1 Philippe May
h2. Mapbox style definition
35 1 Philippe May
36 1 Philippe May
The specification of mapbox paint styles can be found at https://www.mapbox.com/mapbox-gl-js/style-spec/ .
37 1 Philippe May
38 1 Philippe May
For example:
39 1 Philippe May
40 1 Philippe May
<pre>
41 1 Philippe May
{"fill-color": ["rgba", 204, 204, 255, 1]}
42 1 Philippe May
</pre>
43 3 Philippe May
44 6 Philippe May
h2. Fonts
45 6 Philippe May
46 7 Philippe May
Gisaf uses a custom font for symbols: @GisafSymbols@.
47 7 Philippe May
48 7 Philippe May
This same font is used in 2 different ways:
49 7 Philippe May
50 7 Philippe May
1. as normal font for the web interface, using css: eg, the symbols for the layer list.
51 7 Philippe May
52 7 Philippe May
1. for mapbox: Mapbox's rendering uses a WebGL component with its own specification, so the font needs to be converted (see below).
53 7 Philippe May
54 7 Philippe May
55 6 Philippe May
h3. Creation and update of characters
56 6 Philippe May
57 6 Philippe May
The main font file is created with BirdFont, and is in the git repository: @gisaf-app/src/assets/fonts/gisafSymbols.bf@.
58 6 Philippe May
59 6 Philippe May
It is then exported as ttf in Birdfont.
60 6 Philippe May
61 6 Philippe May
62 6 Philippe May
h3. Mapping of characters
63 6 Philippe May
64 6 Philippe May
Each character for a layer has a unicode number, which needs to be mapped to the layer it represents.
65 1 Philippe May
66 7 Philippe May
The mapping is done in 2 different places, according to the 2 techniques quickly described above:
67 7 Philippe May
68 7 Philippe May
1. CSS: In @gisaf-app/src/gisaf-icons.css@, the mapping is like @layer_name => unicode@, eg:
69 7 Philippe May
70 7 Philippe May
<pre>
71 7 Philippe May
.gisaf-V_VEGE_TMPL:before { content: '\e044';}
72 7 Philippe May
</pre>
73 7 Philippe May
74 7 Philippe May
1. Mapbox:
75 7 Philippe May
76 7 Philippe May
 1. For custom models, the Unicode is defined in the @symbols@ attribute
77 7 Philippe May
78 7 Philippe May
 1. For category-based models, the Unicode is defined in the @symbol@ column and can be set through the Gisaf admin.
79 6 Philippe May
80 6 Philippe May
81 6 Philippe May
h3. Build
82 3 Philippe May
83 3 Philippe May
In the @gisaf-app@ directory:
84 3 Philippe May
<pre>
85 3 Philippe May
./node_modules/.bin/build-glyphs src/assets/fonts/GisafSymbols.ttf src/assets/fonts/glyphs/GisafSymbols/
86 3 Philippe May
</pre>