This repository has been archived by the owner on Jan 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
/
labels.mss
341 lines (312 loc) · 9.63 KB
/
labels.mss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
// =====================================================================
// LABELS
// General notes:
// - `text-halo-rasterizer: fast;` gives a noticeable performance
// boost to render times and is recommended for *all* halos.
// ---------------------------------------------------------------------
// Languages
// There are 5 language options in the MapBox Streets vector tiles:
// - Local/default: '[name]'
// - English: '[name_en]'
// - French: '[name_fr]'
// - Spanish: '[name_es]'
// - German: '[name_de]'
@name: '[name_en]';
// ---------------------------------------------------------------------
// Fonts
// All fontsets should have a good fallback that covers as many glyphs
// as possible.
@fallback: 'Arial Unicode MS Regular';
@sans: 'Open Sans Regular', @fallback;
@sans_md: 'Open Sans Semibold', @fallback;
@sans_bd: 'Open Sans Bold', 'Arial Unicode MS Bold', @fallback;
@sans_it: 'Open Sans Italic', @fallback;
@sans_lt_italic: 'Open Sans Light Italic', @fallback;
@sans_lt: 'Open Sans Light', @fallback;
@place_halo: #fff;
@country_text: @land * 0.2;
@country_halo: @place_halo;
// ---------------------------------------------------------------------
// Countries
// The country labels in MapBox Streets vector tiles are placed by hand,
// optimizing the arrangement to fit as many as possible in densely-
// labeled areas.
#country_label[zoom>=2][zoom<=10] {
text-name: @name;
text-face-name: @sans_bd;
[zoom=2] { text-face-name: @sans; }
text-placement: point;
text-size: 9;
text-fill: @country_text;
text-halo-fill: @country_halo;
text-halo-radius: 1;
text-halo-rasterizer: fast;
text-wrap-width: 20;
text-wrap-before: true;
text-line-spacing: -3;
[scalerank=1] {
[zoom=3] { text-size: 12; text-wrap-width: 60; }
[zoom=4] { text-size: 14; text-wrap-width: 90; }
[zoom=5] { text-size: 20; text-wrap-width: 120; }
[zoom>=6] { text-size: 20; text-wrap-width: 120; }
}
[scalerank=2] {
[zoom=2] { text-name: [code]; }
[zoom=3] { text-size: 11; }
[zoom=4] { text-size: 13; }
[zoom=5] { text-size: 17; }
[zoom>=6] { text-size: 20; }
}
[scalerank=3] {
[zoom=3] { text-name: [code]; }
[zoom=4] { text-size: 11; }
[zoom=5] { text-size: 15; }
[zoom=6] { text-size: 17; }
[zoom=7] { text-size: 18; text-wrap-width: 60; }
[zoom>=8] { text-size: 20; text-wrap-width: 120; }
}
[scalerank=4] {
[zoom=5] { text-size: 13; }
[zoom=6] { text-size: 15; text-wrap-width: 60 }
[zoom=7] { text-size: 16; text-wrap-width: 90; }
[zoom=8] { text-size: 18; text-wrap-width: 120; }
[zoom>=9] { text-size: 20; text-wrap-width: 120; }
}
[scalerank=5] {
[zoom=5] { text-size: 11; }
[zoom=6] { text-size: 13; }
[zoom=7] { text-size: 14; text-wrap-width: 60; }
[zoom=8] { text-size: 16; text-wrap-width: 90; }
[zoom>=9] { text-size: 18; text-wrap-width: 120; }
}
[scalerank>=6] {
[zoom=7] { text-size: 12; }
[zoom=8] { text-size: 14; }
[zoom>=9] { text-size: 16; }
}
}
// ---------------------------------------------------------------------
// Marine
#marine_label[zoom>=2]["mapnik::geometry_type"=1],
#marine_label[zoom>=2]["mapnik::geometry_type"=2] {
text-name: @name;
text-face-name: @sans_lt_italic;
text-fill: lighten(@water,20);
["mapnik::geometry_type"=1] {
text-placement: point;
text-wrap-width: 30;
}
["mapnik::geometry_type"=2] {
text-placement: line;
}
[labelrank=1][zoom>=2],
[labelrank=2][zoom>=3],
[labelrank=3][zoom>=4],
[labelrank=4][zoom>=5],
[labelrank=5][zoom>=6],
[labelrank=6][zoom>=7] {
text-size: 13;
text-character-spacing: 1;
}
[labelrank=1][zoom>=3],
[labelrank=2][zoom>=4],
[labelrank=3][zoom>=5],
[labelrank=4][zoom>=6],
[labelrank=5][zoom>=7],
[labelrank=6][zoom>=8] {
text-size: 16;
text-character-spacing: 2;
}
[labelrank=1][zoom>=4],
[labelrank=2][zoom>=5],
[labelrank=3][zoom>=6] {
text-size: 20;
text-character-spacing: 4;
}
[labelrank=1][zoom>=5],
[labelrank=2][zoom>=6],
[labelrank=3][zoom>=7] {
text-size: 24;
text-character-spacing: 8;
}
}
// ---------------------------------------------------------------------
// Cities, towns, villages, etc
// City labels with dots for low zoom levels.
// The separate attachment keeps the size of the XML down.
#place_label::citydots[type='city'][zoom>=4][zoom<=7][localrank=1] {
// explicitly defining all the `ldir` values wer'e going
// to use shaves a bit off the final project.xml size
[ldir='N'],[ldir='S'],[ldir='E'],[ldir='W'],
[ldir='NE'],[ldir='SE'],[ldir='SW'],[ldir='NW'] {
shield-file: url("shield/dot.svg");
shield-unlock-image: true;
shield-name: @name;
shield-size: 12;
[zoom=7] { shield-size: 14; }
shield-face-name: @sans;
shield-placement: point;
shield-fill: #333;
shield-halo-fill: fadeout(#fff, 50%);
shield-halo-radius: 1;
shield-halo-rasterizer: fast;
[ldir='E'] { shield-text-dx: 5; }
[ldir='W'] { shield-text-dx: -5; }
[ldir='N'] { shield-text-dy: -5; }
[ldir='S'] { shield-text-dy: 5; }
[ldir='NE'] { shield-text-dx: 4; shield-text-dy: -4; }
[ldir='SE'] { shield-text-dx: 4; shield-text-dy: 4; }
[ldir='SW'] { shield-text-dx: -4; shield-text-dy: 4; }
[ldir='NW'] { shield-text-dx: -4; shield-text-dy: -4; }
}
}
#place_label[zoom>=8][localrank=1] {
text-name: @name;
text-face-name: @sans;
text-wrap-width: 120;
text-wrap-before: true;
text-fill: #333;
text-halo-fill: fadeout(#fff, 50%);
text-halo-radius: 1;
text-halo-rasterizer: fast;
text-size: 10;
[type='city'] {
text-face-name: @sans_md;
text-size: 16;
[zoom>=10] {
text-size: 18;
text-wrap-width: 140;
}
[zoom>=12] {
text-size: 24;
text-wrap-width: 180;
}
// Hide at largest scales:
[zoom>=16] { text-name: "''"; }
}
[type='town'] {
text-size: 14;
[zoom>=12] { text-size: 16; }
[zoom>=14] { text-size: 20; }
[zoom>=16] { text-size: 24; }
// Hide at largest scales:
[zoom>=18] { text-name: "''"; }
}
[type='village'] {
text-size: 12;
[zoom>=12] { text-size: 14; }
[zoom>=14] { text-size: 18; }
[zoom>=16] { text-size: 22; }
}
[type='hamlet'],
[type='suburb'],
[type='neighbourhood'] {
text-fill: #633;
text-face-name: @sans_bd;
text-transform: uppercase;
text-character-spacing: 0.5;
[zoom>=14] { text-size: 11; }
[zoom>=15] { text-size: 12; text-character-spacing: 1; }
[zoom>=16] { text-size: 14; text-character-spacing: 2; }
}
}
// ---------------------------------------------------------------------
// Points of interest
#poi_label[zoom=14][scalerank<=1],
#poi_label[zoom=15][scalerank<=2],
#poi_label[zoom=16][scalerank<=3],
#poi_label[zoom=17][scalerank<=4][localrank<=2],
#poi_label[zoom>=18] {
// Separate icon and label attachments are created to ensure that
// all icon placement happens first, then labels are placed only
// if there is still room.
::icon[maki!=null] {
// The [maki] field values match a subset of Maki icon names, so we
// can use that in our url expression.
// Not all POIs have a Maki icon assigned, so we limit this section
// to those that do. See also <https://www.mapbox.com/maki/>
marker-fill:#666;
marker-file:url('icon/[maki]-12.svg');
}
::label {
text-name: @name;
text-face-name: @sans_md;
text-size: 12;
text-fill: #666;
text-halo-fill: fadeout(#fff, 50%);
text-halo-radius: 1;
text-halo-rasterizer: fast;
text-wrap-width: 70;
text-line-spacing: -1;
//text-transform: uppercase;
//text-character-spacing: 0.25;
// POI labels with an icon need to be offset:
[maki!=null] { text-dy: 8; }
}
}
// ---------------------------------------------------------------------
// Roads
#road_label::shield-pt[class='motorway'][zoom>=7][zoom<=10][localrank=1][reflen<=6],
#road_label::shield-pt[class='motorway'][zoom>=9][zoom<=10][localrank=1][reflen<=6],
#road_label::shield-ln[zoom>=11][reflen<=6] {
shield-name: "[ref].replace('·', '\n')";
shield-size: 9;
shield-line-spacing: -4;
shield-file: url('shield/[shield]-[reflen].svg');
shield-face-name: @sans;
shield-fill: #333;
[zoom>=14] {
shield-transform: scale(1.25,1.25);
shield-size: 11;
}
}
#road_label::shield-pt[class='motorway'][zoom>=7][zoom<=10][localrank=1][reflen<=6],
#road_label::shield-pt[class='motorway'][zoom>=9][zoom<=10][localrank=1][reflen<=6] {
shield-placement: point;
shield-avoid-edges: false;
}
#road_label::shield-ln[zoom>=11][reflen<=6] {
shield-placement: line;
shield-spacing: 400;
shield-min-distance: 100;
shield-avoid-edges: true;
}
#road_label {
text-name: @name;
text-placement: line; // text follows line path
text-face-name: @sans;
text-fill: #765;
text-halo-fill: fadeout(#fff, 50%);
text-halo-radius: 1;
text-halo-rasterizer: fast;
text-size: 12;
text-avoid-edges: true; // prevents clipped labels at tile edges
[zoom>=15] { text-size: 13; }
}
// ---------------------------------------------------------------------
// Water
#water_label {
[zoom<=13], // automatic area filtering @ low zooms
[zoom>=14][area>500000],
[zoom>=16][area>10000],
[zoom>=17] {
text-name: @name;
text-face-name: @sans_it;
text-fill: darken(@water, 15);
text-size: 12;
text-wrap-width: 100;
text-wrap-before: true;
text-halo-fill: fadeout(#fff, 75%);
text-halo-radius: 1.5;
}
}
// ---------------------------------------------------------------------
// House numbers
#housenum_label[zoom>=18] {
text-name: [house_num];
text-face-name: @sans_it;
text-fill: #cba;
text-size: 8;
[zoom=19] { text-size: 10; }
[zoom>=20] { text-size: 12; }
}