Screencast

Part 2 of using TileMill. We’ll make some decent street renderings (based on DC Maps), use SVG markers, show raster imagery, and hack TileMill to do 2.5D buildings based on a field value.

Main Styles

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
Map {
background-color: #fff;
}

#buildings {
[zoom > 14] {
line-color:#594;
line-width:0.5;
polygon-fill: #ccc;
polygon-opacity: 1;
}
[zoom >=16] {
building-height: "[HEIGHT] * .75";
building-fill: #ccc;
building-fill-opacity: 0.6;
}
}


#trees {
[zoom = 16] {
marker-width:2;
marker-fill: #6FBF4D;
marker-opacity: 0.8;
marker-line-color: #40821F;
marker-allow-overlap: true;
}
[zoom > 16] {
point-file: url(images/tree.svg);
point-transform:"scale(0.15)";
}
[zoom = 18] {
point-transform: "scale(0.3)";
}
}


#relief {
raster-opacity:1;
}

#hillshade {
[zoom < 16] {
raster-opacity: 0.5
}
}

#slopeshade {
[zoom < 16] {
raster-opacity: 0.10;
}
}

Road Style

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
@motorway: #F8D6E0; /* #90BFE0 */
@trunk: #FFFABB;
@primary: @trunk;

@road: #bbb;
@secondary: @road;
@track: @road;

@font_reg: "Ubuntu Regular","Arial Regular","DejaVu Sans Book";


/* ---- ROAD COLORS ---- */

/*.highway.line { line-color: #f00; } /* debug */

.highway[stylegroup='HIGHWAY'] {
.line[zoom>=7] {
line-color:spin(darken(@motorway,36),-10);
line-cap:round;
line-join:round;
}
.fill[zoom>=10] {
line-color:@motorway;
line-cap:round;
line-join:round;
}
}

.highway[stylegroup='RAMP'] {
.line[zoom>=7] {
line-color:spin(darken(@motorway,36),-10);
line-cap:round;
line-join:round;
}
.fill[zoom>=12] {
line-color:@motorway;
line-cap:round;
line-join:round;
}
}

.highway[stylegroup='PRIMARY']{
.line[zoom>=7] {
line-color:spin(darken(@primary,36),-10);
line-cap:round;
line-join:round;
}
.fill[zoom>=12] {
line-color:@primary;
line-cap:round;
line-join:round;
}
}

.highway[stylegroup='SECONDARY'] {
.line[zoom>=10] {
line-color:@road;
line-cap:round;
line-join:round;
}
.fill[zoom>=15] {
line-color:#fff;
line-cap:round;
line-join:round;
}
}



/* ---- ROAD WIDTHS ---- */

.highway[zoom=13] {
.line[stylegroup='HIGHWAY'] { line-width: 2.0 + 2; }
.fill[stylegroup='HIGHWAY'] { line-width: 2.0; }
.line[stylegroup='PRIMARY'] { line-width: 1.2 + 2; }
.fill[stylegroup='PRIMARY'] { line-width: 1.2; }
.line[stylegroup='RAMP'] { line-width: 1.0 + 2; }
.fill[stylegroup='RAMP'] { line-width: 1.0; }
.line[stylegroup='SECONDARY'] { line-width: 1.0; }
}

.highway[zoom=14] {
.line[stylegroup='HIGHWAY'] { line-width: 4 + 2; }
.fill[stylegroup='HIGHWAY'] { line-width: 4; }
.line[stylegroup='PRIMARY'] { line-width: 2 + 2; }
.fill[stylegroup='PRIMARY'] { line-width: 2; }
.line[stylegroup='RAMP'] { line-width: 1.4 + 2; }
.fill[stylegroup='RAMP'] { line-width: 1.4; }
.line[stylegroup='SECONDARY'] { line-width: 1.0; }
}

.highway[zoom=15] {
.line[stylegroup='HIGHWAY'] { line-width: 6 + 2; }
.fill[stylegroup='HIGHWAY'] { line-width: 6; }
.line[stylegroup='PRIMARY'] { line-width: 4 + 2; }
.fill[stylegroup='PRIMARY'] { line-width: 4; }
.line[stylegroup='RAMP'] { line-width: 2 + 2; }
.fill[stylegroup='RAMP'] { line-width: 2; }
.line[stylegroup='SECONDARY'] { line-width: 4 + 2; }
.fill[stylegroup='SECONDARY'] { line-width: 4; }
}

.highway[zoom=16] {
.line[stylegroup='HIGHWAY'] { line-width: 9 + 3; }
.fill[stylegroup='HIGHWAY'] { line-width: 9; }
.line[stylegroup='PRIMARY'] { line-width: 7 + 2; }
.fill[stylegroup='PRIMARY'] { line-width: 7; }
.line[stylegroup='RAMP'] { line-width: 3 + 2.5; }
.fill[stylegroup='RAMP'] { line-width: 3; }
.line[stylegroup='SECONDARY'] { line-width: 6 + 2; }
.fill[stylegroup='SECONDARY'] { line-width: 6; }
}

.highway[zoom>=17] {
.line[stylegroup='HIGHWAY'] { line-width: 13 + 3; }
.fill[stylegroup='HIGHWAY'] { line-width: 13; }
.line[stylegroup='PRIMARY'] { line-width: 9 + 2; }
.fill[stylegroup='PRIMARY'] { line-width: 9; }
.line[stylegroup='RAMP'] { line-width: 4 + 2.5; }
.fill[stylegroup='RAMP'] { line-width: 4; }
.line[stylegroup='SECONDARY'] { line-width: 8 + 2; }
.fill[stylegroup='SECONDARY'] { line-width: 8; }
}

/* ---- ONE WAY ARROWS ---- */

.highway.fill::oneway_arrow[zoom>15][oneway > 0] {
marker-type:arrow;
marker-width:1;
marker-line-width:1;
marker-line-opacity:0.5;
marker-line-color:#fff;
marker-spacing: 200;
marker-fill:spin(darken(@motorway,50),-10);
marker-opacity:0.8;
}

/* ---- HIGHWAY ---- */

.highway-labels {
text-face-name:@font_reg;
text-halo-radius:1;
text-placement:line;
text-name:"''";
text-min-distance: 500;
[stylegroup='HIGHWAY'][zoom>=12] {
text-name:"[wholestnam]";
text-halo-fill:lighten(@motorway,8);
[zoom>=13] { text-size:11; }
[zoom>=15] { text-size:12; }
}
[stylegroup="PRIMARY"][zoom>=13] {
text-name:"[wholestnam]";
text-fill:spin(darken(@primary,70),-15);
text-halo-fill:lighten(@primary,8);
[zoom>=15] { text-size:11; }
}
[stylegroup='SECONDARY'][zoom>=16] {
text-name:"[wholestnam]";
text-fill:#444;
text-halo-fill:#fff;
}
}

Resources