1
1
---
2
- layout: default
2
+ layout: base
3
3
---
4
4
< link rel ="
stylesheet "
href ="
https://cdn.jsdelivr.net/npm/[email protected] /dist/maplibre-gl.css "
integrity ="
sha256-V2sIX92Uh6ZaGSFTKMHghsB85b9toJtmazgG09AI2uk= "
crossorigin ="
anonymous "
>
5
5
6
- < div class ="route ">
6
+ < div class ="route container ">
7
7
< h1 title ="{{ page.id }} " class ="mb-0 h2 "> {{ page.title }}</ h1 >
8
8
{% assign ascent_ft = page.ascent_m | times: 3.28084 %}
9
9
{% assign descent_ft = page.descent_m | times: 3.28084 %}
@@ -12,9 +12,8 @@ <h3 class="h5"><span title="{{ page.distance_mi | times: 1.609 | round: 1}}km">{
12
12
< a class ="btn btn-sm btn-outline-primary " href ="{{ page.gpx | relative_url }} " data-goatcounter-click ="download-{{ page.id }} "> Download GPX</ a > {% if page.map %}< a class ="btn btn-sm btn-outline-primary " href ="{{page.map}} " data-goatcounter-click ="ext-map-{{ page.id }} "> OnTheGoMap</ a > {% endif %}
13
13
</ div >
14
14
< h2 class ="visually-hidden "> Map</ h2 >
15
- < div id ="map " style =" height: 500px; " class ="mb-3 w-100 "> </ div >
15
+ < div id ="map " class ="mb-3 w-100 "> </ div >
16
16
< elevation-profile class ="mb-3 "> </ elevation-profile >
17
-
18
17
< div > < b > Start:</ b > {{ page.start }} {% for location in site.data.locations.features %}
19
18
{% if location.properties.id == page.start and location.properties.meeting_point_desc %}
20
19
< span class ="text-secondary ms-1 "> {{ location.properties.meeting_point_desc }}</ span >
@@ -61,6 +60,10 @@ <h2 class="visually-hidden">Map</h2>
61
60
</ div >
62
61
63
62
< style >
63
+ # map {
64
+ height : 60vh ;
65
+ min-height : 500px ;
66
+ }
64
67
elevation-profile {
65
68
--ep-fill-color : darkgray;
66
69
--ep-line-color : # ccc ;
@@ -147,47 +150,15 @@ <h2 class="visually-hidden">Map</h2>
147
150
return bounds . extend ( coord ) ;
148
151
} , new maplibregl . LngLatBounds ( coordinates [ 0 ] , coordinates [ 0 ] ) ) ;
149
152
const map = new maplibregl . Map ( {
150
- style : 'https://tiles.openfreemap.org/styles/liberty ' ,
153
+ style : '{{ site.baseurl }}/maps/route-map-style.json ' ,
151
154
container : 'map' ,
152
155
zoom : 9.5 ,
153
156
center : [ - 122.3321 , 47.6062 ] ,
154
157
bounds : bounds ,
155
158
fitBoundsOptions : { padding : 50 , animate : false }
156
159
} ) ;
157
160
map . on ( 'load' , function ( ) {
158
-
159
- map . addSource ( 'route' , {
160
- 'type' : 'geojson' ,
161
- 'data' : data
162
- } ) ;
163
- map . addLayer ( {
164
- 'id' : 'route' ,
165
- 'type' : 'line' ,
166
- 'source' : 'route' ,
167
- 'layout' : {
168
- 'line-join' : 'round' ,
169
- 'line-cap' : 'round'
170
- } ,
171
- 'paint' : {
172
- 'line-color' : 'rgba(0, 0, 255, 0.6)' ,
173
- 'line-width' : 3
174
- }
175
- } ) ;
176
- map . addLayer ( {
177
- 'id' : 'route-hover-region' ,
178
- 'type' : 'line' ,
179
- 'source' : 'route' ,
180
- 'layout' : {
181
- 'line-join' : 'round' ,
182
- 'line-cap' : 'round'
183
- } ,
184
- 'paint' : {
185
- 'line-color' : 'rgba(0, 0, 255, 0)' ,
186
- 'line-width' : 10
187
- }
188
- } ) ;
189
-
190
-
161
+ map . getSource ( 'route' ) . setData ( data ) ;
191
162
// Frame the route
192
163
193
164
let totalDistance = 0
@@ -213,91 +184,37 @@ <h2 class="visually-hidden">Map</h2>
213
184
}
214
185
}
215
186
216
- map . addSource ( 'terrain_rgb' , {
217
- type : 'raster-dem' ,
218
- url : 'pmtiles://https://static.raceconditionrunning.com/seattle_dem.pmtiles' ,
219
- tileSize : 512
220
- } ) ;
221
- map . addLayer ( {
222
- id : 'terrain_rgb' ,
223
- type : 'hillshade' ,
224
- source : 'terrain_rgb' ,
225
- minzoom : 0 ,
226
- maxzoom : 12
227
- } ) ;
228
- map . setTerrain ( { source : 'terrain_rgb' , exaggeration : 2.0 } )
229
- map . addSource ( 'distance-labels' , {
230
- type : 'geojson' ,
231
- data : {
232
- type : 'FeatureCollection' ,
233
- features : distanceLabels
234
- }
235
- } )
236
- map . addLayer ( {
237
- 'id' : 'distance-labels' ,
238
- 'type' : 'symbol' ,
239
- 'source' : 'distance-labels' ,
240
- "minzoom" : 9 ,
241
- "layout" : {
242
- "text-field" : [ "to-string" , [ "get" , "distance" ] ] ,
243
- "text-font" : [ "Noto Sans Regular" ] ,
244
- "text-size" : {
245
- "stops" : [
246
- [ 9 , 10 ] ,
247
- [ 10 , 11 ] ,
248
- [ 16 , 18 ]
249
- ]
250
- } ,
251
- "text-padding" : 4 ,
252
- "text-justify" : "center"
253
- } ,
254
- "paint" : {
255
- "text-color" : "#FFF" ,
256
- "text-halo-color" : "rgba(0, 0, 0, 0.8)" ,
257
- "text-halo-width" : 2
258
- }
259
- } )
187
+ map . getSource ( 'distance-labels' ) . setData ( {
188
+ type : 'FeatureCollection' ,
189
+ features : distanceLabels
190
+ } ) ;
191
+
260
192
261
- map . addSource ( 'points' , {
262
- type : 'geojson' ,
263
- data : {
264
- type : 'FeatureCollection' ,
265
- features : [
266
- {
267
- type : 'Feature' ,
268
- geometry : {
269
- type : 'Point' ,
270
- coordinates : coordinates [ 0 ]
271
- } ,
272
- properties : {
273
- color : '#00FF00'
274
- }
193
+ map . getSource ( 'points' ) . setData ( {
194
+ type : 'FeatureCollection' ,
195
+ features : [
196
+ {
197
+ type : 'Feature' ,
198
+ geometry : {
199
+ type : 'Point' ,
200
+ coordinates : coordinates [ 0 ]
275
201
} ,
276
- {
277
- type : 'Feature' ,
278
- geometry : {
279
- type : 'Point' ,
280
- coordinates : coordinates [ coordinates . length - 1 ]
281
- } ,
282
- properties : {
283
- color : '#FF0000'
284
- }
202
+ properties : {
203
+ color : '#00FF00'
285
204
}
286
- ]
287
- }
288
- } ) ;
205
+ } ,
206
+ {
207
+ type : 'Feature' ,
208
+ geometry : {
209
+ type : 'Point' ,
210
+ coordinates : coordinates [ coordinates . length - 1 ]
211
+ } ,
212
+ properties : {
213
+ color : '#FF0000'
214
+ }
215
+ }
216
+ ]
289
217
290
- map . addLayer ( {
291
- id : "colored-dots" ,
292
- type : "circle" ,
293
- source : "points" ,
294
- paint : {
295
- "circle-color" : [ "get" , "color" ] ,
296
- "circle-radius" : 5 ,
297
- "circle-opacity" : 0.8 ,
298
- "circle-stroke-color" : "#000" ,
299
- "circle-stroke-width" : 1
300
- }
301
218
} ) ;
302
219
303
220
// Create a popup, but don't add it to the map yet.
0 commit comments