Skip to content

Commit c8ad5db

Browse files
committed
rename route -> navigation.
add cycle routes. display more text at weird angles and lower zoom levels. remove "style-normal" and support "default" in the code.
1 parent 5d411fa commit c8ad5db

14 files changed

+63
-25
lines changed

buttons.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
"active": true,
77
"name": "",
88
"source": [
9+
{ "id": "routes", "class": "layerIds", "active": false, "layerIds": {
10+
"cycle-route": [{"propertyType": "layout", "property": "visibility", "value": "visible"}]
11+
}},
912
{ "id": "gravel-road", "class": "layerIds", "active": false, "layerIds": {
1013
"road-unpaved": [{"propertyType": "layout", "property": "visibility", "value": "visible"}]
1114
}},
@@ -17,7 +20,7 @@
1720
"cycleway-paved": [{"propertyType": "layout", "property": "visibility", "value": "visible"}],
1821
"cyclefriendly-paved": [{"propertyType": "layout", "property": "visibility", "value": "visible"}]
1922
}},
20-
{ "id": "route", "class": "route" },
23+
{ "id": "navigation", "class": "navigation" },
2124
{
2225
"id": "satellite",
2326
"class": "layer",

dist/cyclemaps.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@
135135
.guage {
136136
display: inline-block;
137137
}
138+
#routes {
139+
background-color: hsl(0, 20%, 60%);
140+
}
141+
#routes.active {
142+
background-color: hsl(0, 100%, 50%);
143+
}
138144
#gravel-road {
139145
background-color: hsl(0, 0%, 75%);
140146
}

src/button.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
import { MainControl } from './main.js';
3-
import { RouteControl } from './route.js';
3+
import { NavigationControl } from './navigation.js';
44
import * as util from './util.js';
55

66
import { IControl, Popup, LayerSpecification, SourceSpecification, Map, MapMouseEvent, MapLayerMouseEvent, MapGeoJSONFeature } from 'maplibre-gl';
@@ -280,18 +280,18 @@ class RainButton extends LayerButton {
280280
}
281281
}
282282

283-
class RouteButton extends Button {
284-
routeControl: RouteControl;
283+
class NavigationButton extends Button {
284+
navigationControl: NavigationControl;
285285
constructor(layer: CyclemapLayerSpecification, buttonControl: ButtonControl) {
286286
super(layer, buttonControl);
287-
this.routeControl = new RouteControl();
287+
this.navigationControl = new NavigationControl();
288288
}
289289
select() {
290290
super.select();
291-
this.buttonControl.map!.addControl(this.routeControl);
291+
this.buttonControl.map!.addControl(this.navigationControl);
292292
}
293293
deselect() {
294-
this.buttonControl.map!.removeControl(this.routeControl);
294+
this.buttonControl.map!.removeControl(this.navigationControl);
295295
super.deselect();
296296
}
297297
}
@@ -487,7 +487,7 @@ export class ButtonControl implements IControl {
487487
about: layer => new AboutButton(layer, this),
488488
layerIds: layer => new LayerIdsButton(layer, this),
489489
externalLink: layer => new ExternalLinkButton(layer, this),
490-
route: layer => new RouteButton(layer, this),
490+
navigation: layer => new NavigationButton(layer, this),
491491
};
492492

493493
generateButton(layer: CyclemapLayerSpecification) {

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export class MainControl implements IControl {
115115
Cookies.set('style', style, cookieAttributes);
116116
}
117117

118-
return styleRoot + (style != null ? style : 'style.json');
118+
return styleRoot + (style != null && style != 'default' ? style : 'style.json');
119119
}
120120

121121
getButtonsQuery() {

src/route.ts renamed to src/navigation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { IControl, Map } from 'maplibre-gl';
77
const DURATION_RATIO = 0.7; //discount the duration, mapbox cycling speed is crazy-slow
88
const CYCLEMAPS_MAPBOX_PUBLIC_ACCESS_TOKEN = process.env.CYCLEMAPS_MAPBOX_PUBLIC_ACCESS_TOKEN;
99

10-
export class RouteControl implements IControl {
10+
export class NavigationControl implements IControl {
1111
map: Map | undefined;
1212
directions: MapLibreGlDirections | undefined;
1313
dummyContainer: HTMLElement | undefined;

style-highlight.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

style-input.json

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,6 @@
298298
]
299299
]
300300
},
301-
"line-opacity": 1,
302301
"line-width": {
303302
"base": 1.4,
304303
"stops": [
@@ -343,7 +342,6 @@
343342
},
344343
"paint": {
345344
"line-color": "hsl(205, 56%, 73%)",
346-
"line-opacity": 1,
347345
"line-width": {
348346
"base": 1.4,
349347
"stops": [
@@ -392,7 +390,6 @@
392390
2,
393391
1
394392
],
395-
"line-opacity": 1,
396393
"line-width": {
397394
"base": 1.4,
398395
"stops": [
@@ -896,7 +893,6 @@
896893
},
897894
"paint": {
898895
"line-color": "hsl(0, 0%, 100%)",
899-
"line-opacity": 1,
900896
"line-width": {
901897
"base": 1.5,
902898
"stops": [
@@ -939,7 +935,6 @@
939935
},
940936
"paint": {
941937
"line-color": "hsl(0, 0%, 100%)",
942-
"line-opacity": 1,
943938
"line-width": {
944939
"base": 1.5,
945940
"stops": [
@@ -1762,6 +1757,41 @@
17621757
"source-layer": "transportation",
17631758
"type": "line"
17641759
},
1760+
{
1761+
"id": "cycle-route",
1762+
"type": "line",
1763+
"source": "openmaptiles",
1764+
"source-layer": "cycleroute",
1765+
"filter": [
1766+
"all",
1767+
[
1768+
"==",
1769+
"$type",
1770+
"LineString"
1771+
]
1772+
],
1773+
"layout": {
1774+
"line-cap": "round",
1775+
"line-join": "round",
1776+
"visibility": "none"
1777+
},
1778+
"paint": {
1779+
"line-color": "hsl(0, 100%, 50%, 75%)",
1780+
"line-width": {
1781+
"base": 1.1,
1782+
"stops": [
1783+
[
1784+
5,
1785+
1
1786+
],
1787+
[
1788+
20,
1789+
6
1790+
]
1791+
]
1792+
}
1793+
}
1794+
},
17651795
{
17661796
"id": "admin_sub",
17671797
"type": "line",
@@ -2029,7 +2059,7 @@
20292059
"type": "symbol",
20302060
"source": "openmaptiles",
20312061
"source-layer": "transportation_name",
2032-
"minzoom": 13,
2062+
"minzoom": 9,
20332063
"filter": [
20342064
"==",
20352065
"$type",
@@ -2056,6 +2086,7 @@
20562086
"Noto Sans Regular"
20572087
],
20582088
"text-letter-spacing": 0.1,
2089+
"text-max-angle": 360,
20592090
"text-rotation-alignment": "map",
20602091
"text-size": {
20612092
"base": 1.4,

style-normal.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

style-openmaptiles.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)