DAVIDG~1.txt
  • About
  • Posts
  • Photography
  • Gadgets

DIY vector mapping - Fri, Sep 2, 2022

Toolchain for creating custom self-hosted vector maps (Tippecanoe, Maplibre GL, TileServer-GL), adding a bit of geospatial bling to Flight Sim blog posts

Intro

This post is testing HTML-in-Markdown embedding of a custom MapLibre GL Map. I’ll probably use this code in future to add some flair to flight simulator posts.

Points are filtered in order of:

  • Large Airports
  • Medium Airports
  • Small airports
  • Everything else (e.g. heliports, seaplane bases)

Map vector tiles were created from raw data using the MapBox Tippecanoe tool.

Static Maps

Tileserver-GL can render static images based on parameters given in the URL.

English Channel

Interactive Maps

It can also serve vector tiles to an embedded map renderer, like Maplibre GL.

Click, drag, and scroll to see how the map filters data points based on zoom-level.

Zoom right in and you should see taxiway-level features.



Attributions

Runway & taxiway shape data © OpenStreetMap contributors.

Airport metadata courtesy of OurAirports.

Made with Natural Earth.

The map style is my own work. The JSON code is below, if you wish to recreate it. Any use of OSM data must have appropriate attribution.

Code sample

  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
{
 "version": 8,
 "name": "Radar",
 "metadata": {"maputnik:renderer": "mbgljs"},
 "sources": {
   "natural_earth.vector": {
     "type": "vector",
     "url": "https://{your_tile_source.json}"
   },
   "latest.planet": {
     "type": "vector",
     "attribution": "<a href='http://openstreetmap.org/copyright'>© OpenStreetMap contributors</a>",
     "url": "https://{your_tile_source.json}"
   },
   "ICAO": {
     "type": "vector",
     "url": "https://{your_tile_source.json}"
   },
   "Graticules_20": {
     "type": "vector",
     "url": "https://{your_tile_source.json}"
   }
 },
 "sprite": "https://{your_url}/sprites/",
 "glyphs": "https://{your_url}/fonts/{fontstack}/{range}.pbf",
 "layers": [
   {"id": "terrain", "type": "background"},
   {
     "id": "water",
     "type": "fill",
     "source": "natural_earth.vector",
     "source-layer": "water",
     "paint": {
       "fill-color": "rgba(0, 7, 79, 1)",
       "fill-outline-color": "rgba(24, 125, 0, 1)"
     }
   },
   {
     "id": "graticules",
     "type": "line",
     "source": "Graticules_20",
     "source-layer": "ne_50m_graticules_20",
     "paint": {
       "line-color": "rgba(191, 180, 155, 1)",
       "line-dasharray": [50, 50],
       "line-width": 0.5,
       "line-opacity": 0.5
     }
   },
   {
     "id": "aeroways_2",
     "type": "line",
     "source": "latest.planet",
     "source-layer": "osm",
     "filter": ["all", ["==", "aeroway", "taxiway"]],
     "layout": {"line-cap": "butt", "line-join": "round"},
     "paint": {
       "line-color": "rgba(175, 175, 63, 1)",
       "line-dasharray": [1],
       "line-opacity": 0.5,
       "line-width": 2,
       "line-gap-width": 3
     }
   },
   {
     "id": "aeroways_1",
     "type": "line",
     "source": "latest.planet",
     "source-layer": "osm",
     "filter": ["all", ["==", "aeroway", "runway"]],
     "layout": {
       "line-cap": "square",
       "line-join": "miter",
       "line-round-limit": 10
     },
     "paint": {
       "line-color": "rgba(255, 255, 255, 1)",
       "line-width": 6,
       "line-dasharray": [1],
       "line-opacity": 0.5,
       "line-gap-width": 2
     }
   },
   {
     "id": "ICAO_points_else",
     "type": "circle",
     "source": "ICAO",
     "source-layer": "gps_codes",
     "minzoom": 9,
     "filter": [
       "!",
       [
         "any",
         [
           "case",
           ["==", ["typeof", ["get", "type"]], "string"],
           ["==", ["get", "type"], "small_airport"],
           false
         ],
         [
           "case",
           ["==", ["typeof", ["get", "type"]], "string"],
           ["==", ["get", "type"], "medium_airport"],
           false
         ],
         [
           "case",
           ["==", ["typeof", ["get", "type"]], "string"],
           ["==", ["get", "type"], "large_airport"],
           false
         ]
       ]
     ],
     "paint": {
       "circle-color": "rgba(149, 0, 255, 0)",
       "circle-stroke-color": "rgba(206, 255, 0, 1)",
       "circle-stroke-width": 1,
       "circle-radius": 2
     }
   },
   {
     "id": "ICAO_points_small",
     "type": "circle",
     "source": "ICAO",
     "source-layer": "gps_codes",
     "minzoom": 6,
     "filter": ["all", ["has", "gps_code"], ["==", "type", "small_airport"]],
     "paint": {
       "circle-color": "rgba(149, 0, 255, 0)",
       "circle-stroke-color": "rgba(0, 79, 255, 1)",
       "circle-stroke-width": 1,
       "circle-radius": 2
     }
   },
   {
     "id": "ICAO_points_medium",
     "type": "circle",
     "source": "ICAO",
     "source-layer": "gps_codes",
     "minzoom": 5,
     "filter": ["all", ["has", "gps_code"], ["==", "type", "medium_airport"]],
     "paint": {
       "circle-color": "rgba(149, 0, 255, 1)",
       "circle-stroke-color": "rgba(136, 192, 218, 1)",
       "circle-stroke-width": 1,
       "circle-radius": 2
     }
   },
   {
     "id": "ICAO_points_large",
     "type": "circle",
     "source": "ICAO",
     "source-layer": "gps_codes",
     "filter": ["all", ["has", "gps_code"], ["==", "type", "large_airport"]],
     "paint": {
       "circle-color": "rgba(235, 0, 255, 1)",
       "circle-stroke-color": "rgba(3, 20, 189, 1)",
       "circle-stroke-width": 1,
       "circle-radius": 4,
       "circle-blur": 0.5
     }
   },
   {
     "id": "ICAO_labels_else",
     "type": "symbol",
     "source": "ICAO",
     "source-layer": "gps_codes",
     "minzoom": 9.5,
     "filter": [
       "!",
       [
         "any",
         [
           "case",
           ["==", ["typeof", ["get", "type"]], "string"],
           ["==", ["get", "type"], "small_airport"],
           false
         ],
         [
           "case",
           ["==", ["typeof", ["get", "type"]], "string"],
           ["==", ["get", "type"], "medium_airport"],
           false
         ],
         [
           "case",
           ["==", ["typeof", ["get", "type"]], "string"],
           ["==", ["get", "type"], "large_airport"],
           false
         ]
       ]
     ],
     "layout": {
       "text-field": [
         "step",
         ["zoom"],
         ["get", "gps_code"],
         0,
         ["get", "gps_code"],
         9,
         ["concat", ["get", "gps_code"], "\n", ["get", "name"]]
       ],
       "text-allow-overlap": false,
       "text-ignore-placement": false,
       "symbol-z-order": "auto",
       "text-padding": 10,
       "text-anchor": "top",
       "text-optional": true,
       "text-variable-anchor": ["left", "right", "top", "bottom"],
       "icon-allow-overlap": true,
       "text-font": ["Open Sans Regular", "Arial Unicode MS Regular"],
       "symbol-avoid-edges": true,
       "symbol-spacing": 100,
       "text-size": 12
     },
     "paint": {"text-color": "rgba(206, 255, 0, 1)", "text-opacity": 1}
   },
   {
     "id": "ICAO_labels_small",
     "type": "symbol",
     "source": "ICAO",
     "source-layer": "gps_codes",
     "minzoom": 8,
     "filter": ["all", ["has", "gps_code"], ["==", "type", "small_airport"]],
     "layout": {
       "text-field": [
         "step",
         ["zoom"],
         ["get", "gps_code"],
         0,
         ["get", "gps_code"],
         9,
         ["concat", ["get", "gps_code"], "\n", ["get", "name"]]
       ],
       "text-allow-overlap": false,
       "text-ignore-placement": false,
       "symbol-z-order": "auto",
       "text-padding": 10,
       "text-anchor": "top",
       "text-optional": true,
       "text-variable-anchor": ["left", "right", "top", "bottom"],
       "icon-allow-overlap": true,
       "text-font": ["Open Sans Regular", "Arial Unicode MS Regular"],
       "symbol-avoid-edges": true,
       "symbol-spacing": 100,
       "text-size": 12
     },
     "paint": {"text-color": "rgba(0, 79, 255, 1)", "text-opacity": 1}
   },
   {
     "id": "ICAO_labels_medium",
     "type": "symbol",
     "source": "ICAO",
     "source-layer": "gps_codes",
     "minzoom": 6,
     "filter": ["all", ["has", "gps_code"], ["==", "type", "medium_airport"]],
     "layout": {
       "text-field": [
         "step",
         ["zoom"],
         ["get", "gps_code"],
         0,
         ["get", "gps_code"],
         8,
         ["concat", ["get", "gps_code"], "\n", ["get", "name"]]
       ],
       "text-allow-overlap": false,
       "text-ignore-placement": false,
       "symbol-z-order": "auto",
       "text-padding": 10,
       "text-anchor": "top",
       "text-optional": true,
       "text-variable-anchor": ["left", "right", "top", "bottom"],
       "icon-allow-overlap": true,
       "text-font": ["Open Sans Regular", "Arial Unicode MS Regular"],
       "symbol-avoid-edges": true,
       "symbol-spacing": 100,
       "text-size": 12
     },
     "paint": {"text-color": "rgba(167, 62, 173, 1)", "text-opacity": 1}
   },
   {
     "id": "ICAO_labels_large",
     "type": "symbol",
     "source": "ICAO",
     "source-layer": "gps_codes",
     "minzoom": 4,
     "filter": ["all", ["has", "gps_code"], ["==", "type", "large_airport"]],
     "layout": {
       "text-field": [
         "step",
         ["zoom"],
         ["get", "gps_code"],
         0,
         ["get", "gps_code"],
         6,
         ["concat", ["get", "gps_code"], "\n", ["get", "name"]]
       ],
       "text-allow-overlap": false,
       "text-ignore-placement": false,
       "symbol-z-order": "auto",
       "text-padding": 10,
       "text-anchor": "top",
       "text-optional": true,
       "text-variable-anchor": ["left", "right", "top", "bottom"],
       "icon-allow-overlap": true,
       "text-font": ["Open Sans Regular", "Arial Unicode MS Regular"],
       "symbol-avoid-edges": true,
       "symbol-spacing": 100,
       "text-size": ["literal", 15],
       "icon-anchor": "left",
       "text-justify": "center"
     },
     "paint": {
       "text-color": "rgba(235, 0, 255, 1)",
       "text-opacity": 1,
       "text-translate": [0, 0]
     }
   },
   {
     "id": "rivers",
     "type": "line",
     "source": "natural_earth.vector",
     "source-layer": "river",
     "minzoom": 4,
     "paint": {"line-color": "rgba(3, 11, 96, 1)"}
   }
 ],
 "attribution": "<a href='http://openstreetmap.org/copyright'>© OpenStreetMap contributors</a>",
 "id": "j148gjx7r",
 "owner": "David Grierson"
}
  

Back to Home


hugo.386 theme by Max le Fou | © David Grierson 2026 | DAVIDGRIERSON.COM | Built on Hugo