@johnmorrisdotca/chikyu-earth 0.67.0 → 0.68.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/NOTICE.md +4 -0
- package/README.md +1 -1
- package/dist/flat/airports-data.d.ts +3 -0
- package/dist/flat/airports-data.js +3250 -0
- package/dist/flat/airports.d.ts +93 -0
- package/dist/flat/airports.js +86 -0
- package/dist/flat/element.d.ts +1 -1
- package/dist/flat/element.js +171 -33
- package/dist/flat/index.d.ts +1 -0
- package/dist/flat/index.js +1 -0
- package/dist/flat/words.js +12 -4
- package/dist/realistic/element-base.js +1 -1
- package/dist/space/element-base.js +1 -1
- package/dist/space/index.d.ts +1 -1
- package/dist/space/index.js +1 -1
- package/dist/space/satellite-layer.d.ts +26 -0
- package/dist/space/satellite-layer.js +43 -6
- package/package.json +1 -1
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { type FlatView } from "./geometry.ts";
|
|
2
|
+
import type { FlatLang } from "./words.ts";
|
|
3
|
+
/**
|
|
4
|
+
* An airport as the flat map holds it: where it is, its IATA code, its name (OurAirports', in English), its country's ISO code and its tier (1 a large airport, 2 a medium one).
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import type { Airport } from "@johnmorrisdotca/chikyu-earth/flat";
|
|
9
|
+
*
|
|
10
|
+
* const narita: Airport = { lon: 140.39, lat: 35.77, iata: "NRT", name: "Narita International Airport", country: "JP", tier: 1 };
|
|
11
|
+
* console.log(narita.iata);
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export interface Airport {
|
|
15
|
+
lon: number;
|
|
16
|
+
lat: number;
|
|
17
|
+
iata: string;
|
|
18
|
+
name: string;
|
|
19
|
+
country: string;
|
|
20
|
+
tier: 1 | 2;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The zoom from which the medium airports are drawn as well as the large ones.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { MEDIUM_FROM_ZOOM } from "@johnmorrisdotca/chikyu-earth/flat";
|
|
28
|
+
*
|
|
29
|
+
* console.log(MEDIUM_FROM_ZOOM);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare const MEDIUM_FROM_ZOOM = 3;
|
|
33
|
+
/**
|
|
34
|
+
* The zoom from which an airport's code is written beside it.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* import { CODES_FROM_ZOOM } from "@johnmorrisdotca/chikyu-earth/flat";
|
|
39
|
+
*
|
|
40
|
+
* console.log(CODES_FROM_ZOOM);
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare const CODES_FROM_ZOOM = 4;
|
|
44
|
+
/**
|
|
45
|
+
* An airport placed on the map: where it falls in the box, in CSS pixels from its top left, and the airport.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* import type { PlacedAirport } from "@johnmorrisdotca/chikyu-earth/flat";
|
|
50
|
+
*
|
|
51
|
+
* const at = (one: PlacedAirport): string => `${one.airport.iata} at ${one.x}, ${one.y}`;
|
|
52
|
+
* console.log(typeof at);
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export interface PlacedAirport {
|
|
56
|
+
x: number;
|
|
57
|
+
y: number;
|
|
58
|
+
airport: Airport;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The airports to draw for a view: the large ones, and the medium ones from zoom 3, greater first, with no two in one small cell of the box (so the whole world shows its greater airports and a closer map more of them). A world wider than the box shows an airport at the other turn of it too.
|
|
62
|
+
*
|
|
63
|
+
* @param view - The view.
|
|
64
|
+
* @param airports - Every airport, the greater first within a tier (`AIRPORT_ROWS` as `Airport`s).
|
|
65
|
+
* @returns The airports placed in the box.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* import { placeAirports } from "@johnmorrisdotca/chikyu-earth/flat";
|
|
70
|
+
*
|
|
71
|
+
* const view = { width: 720, height: 360, centerLon: 0, centerLat: 0, zoom: 1 };
|
|
72
|
+
* const airports = [{ lon: 139.78, lat: 35.55, iata: "HND", name: "Tokyo Haneda Airport", country: "JP", tier: 1 as const }];
|
|
73
|
+
* console.log(placeAirports(view, airports).map((one) => one.airport.iata));
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare function placeAirports(view: FlatView, airports: readonly Airport[]): PlacedAirport[];
|
|
77
|
+
/**
|
|
78
|
+
* What to call an airport: its name, its IATA code and its country, in the page's language (the airport's name is OurAirports', in English; the country's is the package's own, in English or Japanese).
|
|
79
|
+
*
|
|
80
|
+
* @param airport - The airport.
|
|
81
|
+
* @param countryName - The name of its country in the language, or null.
|
|
82
|
+
* @param lang - `en` or `ja`.
|
|
83
|
+
* @returns The line, such as `Narita International Airport (NRT), Japan`.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* import { airportLine } from "@johnmorrisdotca/chikyu-earth/flat";
|
|
88
|
+
*
|
|
89
|
+
* const narita = { lon: 140.39, lat: 35.77, iata: "NRT", name: "Narita International Airport", country: "JP", tier: 1 as const };
|
|
90
|
+
* console.log(airportLine(narita, "Japan", "en"), airportLine(narita, "日本", "ja"));
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export declare function airportLine(airport: Airport, countryName: string | null, lang: FlatLang): string;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// The airports on the flat map: which of them to draw at a view (the greater ones when the whole world is in sight, more as the map is zoomed in, never two in one small cell) and what to call one.
|
|
2
|
+
// Pure: no DOM and no dependency. The rows themselves (`airports-data.ts`, from OurAirports) are loaded only when a map asks for the airports.
|
|
3
|
+
import { pixelsPerDegree, projectFlat } from "./geometry.js";
|
|
4
|
+
/**
|
|
5
|
+
* The zoom from which the medium airports are drawn as well as the large ones.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { MEDIUM_FROM_ZOOM } from "@johnmorrisdotca/chikyu-earth/flat";
|
|
10
|
+
*
|
|
11
|
+
* console.log(MEDIUM_FROM_ZOOM);
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export const MEDIUM_FROM_ZOOM = 3;
|
|
15
|
+
/**
|
|
16
|
+
* The zoom from which an airport's code is written beside it.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { CODES_FROM_ZOOM } from "@johnmorrisdotca/chikyu-earth/flat";
|
|
21
|
+
*
|
|
22
|
+
* console.log(CODES_FROM_ZOOM);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export const CODES_FROM_ZOOM = 4;
|
|
26
|
+
/**
|
|
27
|
+
* The airports to draw for a view: the large ones, and the medium ones from zoom 3, greater first, with no two in one small cell of the box (so the whole world shows its greater airports and a closer map more of them). A world wider than the box shows an airport at the other turn of it too.
|
|
28
|
+
*
|
|
29
|
+
* @param view - The view.
|
|
30
|
+
* @param airports - Every airport, the greater first within a tier (`AIRPORT_ROWS` as `Airport`s).
|
|
31
|
+
* @returns The airports placed in the box.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* import { placeAirports } from "@johnmorrisdotca/chikyu-earth/flat";
|
|
36
|
+
*
|
|
37
|
+
* const view = { width: 720, height: 360, centerLon: 0, centerLat: 0, zoom: 1 };
|
|
38
|
+
* const airports = [{ lon: 139.78, lat: 35.55, iata: "HND", name: "Tokyo Haneda Airport", country: "JP", tier: 1 as const }];
|
|
39
|
+
* console.log(placeAirports(view, airports).map((one) => one.airport.iata));
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export function placeAirports(view, airports) {
|
|
43
|
+
const out = [];
|
|
44
|
+
const codes = view.zoom >= CODES_FROM_ZOOM;
|
|
45
|
+
const cell = codes ? 46 : 16;
|
|
46
|
+
const taken = new Set();
|
|
47
|
+
const turn = 360 * pixelsPerDegree(view);
|
|
48
|
+
const pad = 6;
|
|
49
|
+
for (const airport of airports) {
|
|
50
|
+
if (airport.tier === 2 && view.zoom < MEDIUM_FROM_ZOOM)
|
|
51
|
+
break;
|
|
52
|
+
const at = projectFlat(view, airport.lon, airport.lat);
|
|
53
|
+
if (at.y < -pad || at.y > view.height + pad)
|
|
54
|
+
continue;
|
|
55
|
+
for (const x of [at.x - turn, at.x, at.x + turn]) {
|
|
56
|
+
if (x < -pad || x > view.width + pad)
|
|
57
|
+
continue;
|
|
58
|
+
const key = Math.floor(x / cell) * 4096 + Math.floor(at.y / cell);
|
|
59
|
+
if (taken.has(key))
|
|
60
|
+
continue;
|
|
61
|
+
taken.add(key);
|
|
62
|
+
out.push({ x, y: at.y, airport });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* What to call an airport: its name, its IATA code and its country, in the page's language (the airport's name is OurAirports', in English; the country's is the package's own, in English or Japanese).
|
|
69
|
+
*
|
|
70
|
+
* @param airport - The airport.
|
|
71
|
+
* @param countryName - The name of its country in the language, or null.
|
|
72
|
+
* @param lang - `en` or `ja`.
|
|
73
|
+
* @returns The line, such as `Narita International Airport (NRT), Japan`.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* import { airportLine } from "@johnmorrisdotca/chikyu-earth/flat";
|
|
78
|
+
*
|
|
79
|
+
* const narita = { lon: 140.39, lat: 35.77, iata: "NRT", name: "Narita International Airport", country: "JP", tier: 1 as const };
|
|
80
|
+
* console.log(airportLine(narita, "Japan", "en"), airportLine(narita, "日本", "ja"));
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export function airportLine(airport, countryName, lang) {
|
|
84
|
+
const country = countryName ?? airport.country;
|
|
85
|
+
return lang === "ja" ? `${airport.name}(${airport.iata})、${country}` : `${airport.name} (${airport.iata}), ${country}`;
|
|
86
|
+
}
|
package/dist/flat/element.d.ts
CHANGED
|
@@ -77,7 +77,7 @@ export interface GroupStyle {
|
|
|
77
77
|
*
|
|
78
78
|
* Events: `chikyu-flat-pick` (a satellite under the pointer, tapped, or reached by the keyboard: a `FlatPick`; `detail.id` is null when a tap lands on nothing and clears the choice), `chikyu-flat-filter` (a chip changed which groups or plane are shown: `{ groups, plane }`),
|
|
79
79
|
* `chikyu-flat-planes` (the planes were worked out: `{ planes }`), `chikyu-flat-view` (the reader panned or zoomed: `{ center, zoom }`), `chikyu-flat-look` (the look or how it stands changed: `{ look, state }`), `chikyu-flat-mark` (the Sun's dot or the home diamond was pressed: `{ mark, name, text, lon, lat, place, via }`) and `chikyu-timechange` (`{ time, running }`, at most four a second while time runs).
|
|
80
|
-
* Style it with the custom properties `--chikyu-flat-key-inset` (room kept at the left of the key, for a card lying over the map's left side), `--chikyu-flat-sea`, `--chikyu-flat-land`, `--chikyu-flat-line`, `--chikyu-flat-night`, `--chikyu-flat-aspect`, `--chikyu-flat-aspect-narrow` and `--chikyu-flat-radius`.
|
|
80
|
+
* Style it with the shadow parts `button` (every button and chip), `tip`, `key` and `msg` (`chikyu-flat::part(button) { … }`) and the custom properties `--chikyu-flat-button-radius`, `--chikyu-flat-button-padding`, `--chikyu-flat-button-min-height`, `--chikyu-flat-button-border`, `--chikyu-flat-tip-font-size`, `--chikyu-flat-key-font-size`, `--chikyu-flat-key-inset` (room kept at the left of the key, for a card lying over the map's left side), `--chikyu-flat-sea`, `--chikyu-flat-land`, `--chikyu-flat-line`, `--chikyu-flat-night`, `--chikyu-flat-day`, `--chikyu-flat-terminator`, `--chikyu-flat-aspect`, `--chikyu-flat-aspect-narrow` and `--chikyu-flat-radius`.
|
|
81
81
|
*
|
|
82
82
|
* @example
|
|
83
83
|
* ```ts no-run
|
package/dist/flat/element.js
CHANGED
|
@@ -19,6 +19,7 @@ import { GROUP_COLOURS, PLANE_COLOURS, SPARE_COLOUR, TRACK_SHADOW, TRACK_SUNLIT
|
|
|
19
19
|
import { clusterPlanes, groupFacts } from "./facts.js";
|
|
20
20
|
import { FLATTENED, MAX_ZOOM, clampView, pixelsPerDegree, projectFlat, wrapLongitude, zoomAbout } from "./geometry.js";
|
|
21
21
|
import { trackStateOfScene } from "./track-state.js";
|
|
22
|
+
import { airportLine, placeAirports } from "./airports.js";
|
|
22
23
|
import { pointText, placeOver } from "./marks.js";
|
|
23
24
|
import { PhotoPictures, paintPhoto, readLook } from "./photo.js";
|
|
24
25
|
import { say } from "./words.js";
|
|
@@ -75,13 +76,13 @@ const CSS = `
|
|
|
75
76
|
@container (min-width:600px){.chips{flex-wrap:wrap;overflow:visible}}
|
|
76
77
|
.gap{flex:1 1 0}
|
|
77
78
|
.pair{display:inline-flex;gap:0}
|
|
78
|
-
.pair button:first-child{border-radius:999px 0 0 999px}
|
|
79
|
-
.pair button:last-child{border-radius:0 999px 999px 0;margin-left:-1px}
|
|
80
|
-
button{font:inherit;color:inherit;background:transparent;border:1px solid color-mix(in srgb,currentColor 35%,transparent);border-radius:999px;padding:3px 12px;min-height:32px;cursor:pointer;display:inline-flex;align-items:center;gap:6px}
|
|
79
|
+
.pair button:first-child{border-radius:var(--chikyu-flat-button-radius,999px) 0 0 var(--chikyu-flat-button-radius,999px)}
|
|
80
|
+
.pair button:last-child{border-radius:0 var(--chikyu-flat-button-radius,999px) var(--chikyu-flat-button-radius,999px) 0;margin-left:-1px}
|
|
81
|
+
button{font:inherit;color:inherit;background:transparent;border:var(--chikyu-flat-button-border,1px solid color-mix(in srgb,currentColor 35%,transparent));border-radius:var(--chikyu-flat-button-radius,999px);padding:var(--chikyu-flat-button-padding,3px 12px);min-height:var(--chikyu-flat-button-min-height,32px);cursor:pointer;display:inline-flex;align-items:center;gap:6px}
|
|
81
82
|
button[aria-pressed="true"]{background:color-mix(in srgb,currentColor 14%,transparent);border-color:currentColor}
|
|
82
83
|
button:disabled{opacity:.45;cursor:default}
|
|
83
84
|
button:focus-visible{outline:3px solid #6cd0ff;outline-offset:2px}
|
|
84
|
-
@media (pointer:coarse){button{min-height:44px;padding:6px 14px}}
|
|
85
|
+
@media (pointer:coarse){button{min-height:var(--chikyu-flat-button-min-height,44px);padding:var(--chikyu-flat-button-padding,6px 14px)}}
|
|
85
86
|
.chip .swatch{width:10px;height:10px;border-radius:50%;background:var(--c,#9aa5b1);flex:none}
|
|
86
87
|
.chip .n{opacity:.7;font-variant-numeric:tabular-nums;font-size:.85em}
|
|
87
88
|
.stage{position:relative;flex:1 1 auto;min-height:0;aspect-ratio:var(--chikyu-flat-aspect,2/1);overflow:hidden;border-radius:var(--chikyu-flat-radius,10px);background:var(--chikyu-flat-sea,#0b1830)}
|
|
@@ -93,18 +94,18 @@ canvas{position:absolute;inset:0;width:100%;height:100%;display:block}
|
|
|
93
94
|
.ring{position:absolute;left:0;top:0;width:20px;height:20px;margin:-10px 0 0 -10px;border:2px solid #fff;border-radius:50%;pointer-events:none;box-shadow:0 0 0 1px #000,inset 0 0 0 1px #000}
|
|
94
95
|
.ring.hov{width:14px;height:14px;margin:-7px 0 0 -7px;border-width:1px}
|
|
95
96
|
.ring[hidden],.tip[hidden]{display:none}
|
|
96
|
-
.tip{position:absolute;left:0;top:0;pointer-events:none;background:rgba(8,14,28,.94);color:#fff;padding:4px 8px;border-radius:6px;font-size
|
|
97
|
-
.key{position:absolute;left:8px;bottom:8px;display:flex;flex-wrap:wrap;gap:4px 12px;margin:0;padding:3px 8px;border-radius:6px;background:rgba(8,14,28,.82);color:#fff;font-size
|
|
97
|
+
.tip{position:absolute;left:0;top:0;pointer-events:none;background:rgba(8,14,28,.94);color:#fff;padding:4px 8px;border-radius:6px;font-size:var(--chikyu-flat-tip-font-size,.85em);line-height:1.3;white-space:nowrap;border:1px solid rgba(255,255,255,.3)}
|
|
98
|
+
.key{position:absolute;left:8px;bottom:8px;display:flex;flex-wrap:wrap;gap:4px 12px;margin:0;padding:3px 8px;border-radius:6px;background:rgba(8,14,28,.82);color:#fff;font-size:var(--chikyu-flat-key-font-size,.8em);line-height:1.3;pointer-events:none;max-width:calc(100% - 16px)}
|
|
98
99
|
.key[hidden]{display:none}
|
|
99
100
|
.key span{display:inline-flex;align-items:center;gap:6px}
|
|
100
101
|
.key i{display:inline-block;width:18px;height:0;border-top:3px solid var(--k,#fff);border-radius:2px;box-shadow:0 0 0 1px rgba(0,0,0,.55)}
|
|
101
102
|
button.mark{position:absolute;left:0;top:0;width:26px;height:26px;min-height:0;margin:-13px 0 0 -13px;padding:0;border:0;border-radius:50%;background:transparent;pointer-events:none}
|
|
102
103
|
button.mark[hidden]{display:none}
|
|
103
104
|
button.mark:focus-visible{outline:3px solid #6cd0ff;outline-offset:0}
|
|
104
|
-
.legend{font-size
|
|
105
|
+
.legend{font-size:var(--chikyu-flat-key-font-size,.85em);line-height:1.3;padding-left:var(--chikyu-flat-key-inset,0)}
|
|
105
106
|
.legend[hidden],.legend ul[hidden]{display:none}
|
|
106
|
-
.legend button{min-height:28px;padding:1px 10px;font-size:inherit}
|
|
107
|
-
@media (pointer:coarse){.legend button{min-height:40px}}
|
|
107
|
+
.legend button{min-height:var(--chikyu-flat-button-min-height,28px);padding:var(--chikyu-flat-button-padding,1px 10px);font-size:inherit}
|
|
108
|
+
@media (pointer:coarse){.legend button{min-height:var(--chikyu-flat-button-min-height,40px)}}
|
|
108
109
|
.legend ul{list-style:none;margin:6px 0 0;padding:0;display:flex;flex-wrap:wrap;gap:6px 16px}
|
|
109
110
|
.legend li{display:inline-flex;align-items:center;gap:6px}
|
|
110
111
|
.g{display:inline-flex;align-items:center;justify-content:center;gap:2px;flex:none;width:30px;height:20px;border-radius:4px;background:var(--chikyu-flat-sea,#0b1830)}
|
|
@@ -112,12 +113,14 @@ button.mark:focus-visible{outline:3px solid #6cd0ff;outline-offset:0}
|
|
|
112
113
|
.g.sun::before{content:"";width:10px;height:10px;border-radius:50%;background:#ffd54f;box-shadow:0 0 0 1px rgba(0,0,0,.55)}
|
|
113
114
|
.g.home::before{content:"";width:8px;height:8px;background:#fff;box-shadow:0 0 0 2px #0b1830;transform:rotate(45deg)}
|
|
114
115
|
.g.sat i{width:6px;height:6px}
|
|
116
|
+
.g.airport::before{content:"";width:8px;height:8px;box-sizing:border-box;border-radius:50%;background:#fff;box-shadow:0 0 0 1.5px #040812}
|
|
115
117
|
.g.faint::before{content:"";width:7px;height:7px;border-radius:50%;background:#9aa5b1;opacity:.45}
|
|
116
118
|
.g.chosen::before{content:"";width:12px;height:12px;box-sizing:border-box;border:2px solid #fff;border-radius:50%;box-shadow:0 0 0 1px #000}
|
|
117
119
|
.g.footprint::before{content:"";width:16px;height:16px;box-sizing:border-box;border:1px solid rgba(255,255,255,.8);border-radius:50%;background:rgba(255,255,255,.12)}
|
|
118
120
|
.g.line i{width:20px;height:0;border-radius:2px;background:none;border-top:3px solid var(--c)}
|
|
119
121
|
.g.nasa::before{content:"NASA";font-size:.6em;letter-spacing:.04em;color:#fff}
|
|
120
|
-
.g.
|
|
122
|
+
.g.day{background:linear-gradient(90deg,#4a73a8,#8fb4e6)}
|
|
123
|
+
.g.night{background:linear-gradient(90deg,#1b2f4d,#030812)}
|
|
121
124
|
.g.night-photo{background:radial-gradient(circle at 70% 55%,#ffd98a 0 1px,transparent 2px),radial-gradient(circle at 40% 40%,#ffe9b8 0 1px,transparent 2px),linear-gradient(90deg,#41648f,#02060f)}
|
|
122
125
|
button.credit{position:absolute;right:8px;bottom:8px;display:block;margin:0;padding:2px 8px;min-height:0;border:0;border-radius:6px;background:rgba(8,14,28,.72);color:#fff;font-size:.7em;line-height:1.3;max-width:calc(100% - 16px);text-align:right;cursor:pointer}
|
|
123
126
|
button.credit .full,button.credit[data-open] .short{display:none}
|
|
@@ -142,7 +145,7 @@ button.credit[data-open] .full{display:inline}
|
|
|
142
145
|
*
|
|
143
146
|
* Events: `chikyu-flat-pick` (a satellite under the pointer, tapped, or reached by the keyboard: a `FlatPick`; `detail.id` is null when a tap lands on nothing and clears the choice), `chikyu-flat-filter` (a chip changed which groups or plane are shown: `{ groups, plane }`),
|
|
144
147
|
* `chikyu-flat-planes` (the planes were worked out: `{ planes }`), `chikyu-flat-view` (the reader panned or zoomed: `{ center, zoom }`), `chikyu-flat-look` (the look or how it stands changed: `{ look, state }`), `chikyu-flat-mark` (the Sun's dot or the home diamond was pressed: `{ mark, name, text, lon, lat, place, via }`) and `chikyu-timechange` (`{ time, running }`, at most four a second while time runs).
|
|
145
|
-
* Style it with the custom properties `--chikyu-flat-key-inset` (room kept at the left of the key, for a card lying over the map's left side), `--chikyu-flat-sea`, `--chikyu-flat-land`, `--chikyu-flat-line`, `--chikyu-flat-night`, `--chikyu-flat-aspect`, `--chikyu-flat-aspect-narrow` and `--chikyu-flat-radius`.
|
|
148
|
+
* Style it with the shadow parts `button` (every button and chip), `tip`, `key` and `msg` (`chikyu-flat::part(button) { … }`) and the custom properties `--chikyu-flat-button-radius`, `--chikyu-flat-button-padding`, `--chikyu-flat-button-min-height`, `--chikyu-flat-button-border`, `--chikyu-flat-tip-font-size`, `--chikyu-flat-key-font-size`, `--chikyu-flat-key-inset` (room kept at the left of the key, for a card lying over the map's left side), `--chikyu-flat-sea`, `--chikyu-flat-land`, `--chikyu-flat-line`, `--chikyu-flat-night`, `--chikyu-flat-day`, `--chikyu-flat-terminator`, `--chikyu-flat-aspect`, `--chikyu-flat-aspect-narrow` and `--chikyu-flat-radius`.
|
|
146
149
|
*
|
|
147
150
|
* @example
|
|
148
151
|
* ```ts no-run
|
|
@@ -160,7 +163,7 @@ button.credit[data-open] .full{display:inline}
|
|
|
160
163
|
* ```
|
|
161
164
|
*/
|
|
162
165
|
export class ChikyuFlat extends HTMLElement {
|
|
163
|
-
static observedAttributes = ["paused", "trails", "off", "center", "home-lon", "home-lat", "group", "colour-by", "color-by", "plane", "footprint", "track", "footprint-elevation", "selected", "time", "speed", "estimate-far", "shade", "dot-size", "controls", "lang", "elements-src", "look", "borders", "texture-base", "max-texture"];
|
|
166
|
+
static observedAttributes = ["paused", "trails", "off", "center", "home-lon", "home-lat", "group", "colour-by", "color-by", "plane", "footprint", "track", "footprint-elevation", "selected", "time", "speed", "estimate-far", "shade", "dot-size", "controls", "lang", "elements-src", "look", "borders", "texture-base", "max-texture", "airports"];
|
|
164
167
|
#groups = new Map();
|
|
165
168
|
#index = new Map();
|
|
166
169
|
#shown = null;
|
|
@@ -196,6 +199,8 @@ export class ChikyuFlat extends HTMLElement {
|
|
|
196
199
|
#announced = -Infinity;
|
|
197
200
|
#mapKey = "";
|
|
198
201
|
#look = "map";
|
|
202
|
+
/** The colour of the line of sunrise and sunset as the last draw of the map read it, for the key. */
|
|
203
|
+
#terminatorColour = "#ffc46e";
|
|
199
204
|
#photo = null;
|
|
200
205
|
#photoFailed = false;
|
|
201
206
|
#lookSent = "";
|
|
@@ -208,6 +213,12 @@ export class ChikyuFlat extends HTMLElement {
|
|
|
208
213
|
#legendKey = "";
|
|
209
214
|
#legendOpen = null;
|
|
210
215
|
#faint = false;
|
|
216
|
+
/** The airports are asked for (`airports`), the rows once they are loaded (a chunk fetched only then), the ones drawn at the last draw of the map, and the one pointed at or pressed. */
|
|
217
|
+
#airports = false;
|
|
218
|
+
#airportRows = null;
|
|
219
|
+
#airportAt = [];
|
|
220
|
+
#airportHover = null;
|
|
221
|
+
#airportShown = null;
|
|
211
222
|
#credit;
|
|
212
223
|
#trackKey = "";
|
|
213
224
|
#trackLines = null;
|
|
@@ -527,6 +538,8 @@ export class ChikyuFlat extends HTMLElement {
|
|
|
527
538
|
this.#plane = (value ?? "").trim().toUpperCase();
|
|
528
539
|
else if (name === "footprint")
|
|
529
540
|
this.#footprint = flag(value);
|
|
541
|
+
else if (name === "airports")
|
|
542
|
+
this.#setAirports(flag(value));
|
|
530
543
|
else if (name === "track")
|
|
531
544
|
this.#track = flag(value);
|
|
532
545
|
else if (name === "selected") {
|
|
@@ -556,7 +569,7 @@ export class ChikyuFlat extends HTMLElement {
|
|
|
556
569
|
}
|
|
557
570
|
/** Where the pictures are served from: the `texture-base` attribute, else the package's own `textures/` folder beside this file, as for the realistic Earth. */
|
|
558
571
|
#textureBase() {
|
|
559
|
-
const base = this.getAttribute("texture-base") ?? new URL("../textures/", import.meta.url).href;
|
|
572
|
+
const base = this.getAttribute("texture-base") ?? new URL("../textures/", String(import.meta.url)).href;
|
|
560
573
|
return base.endsWith("/") ? base : `${base}/`;
|
|
561
574
|
}
|
|
562
575
|
/** The widest picture to hold: the `max-texture` attribute, 4096 at most, and 2048 on a device that reports 2 GB of memory or less. */
|
|
@@ -780,7 +793,7 @@ export class ChikyuFlat extends HTMLElement {
|
|
|
780
793
|
#colours() {
|
|
781
794
|
const style = getComputedStyle(this);
|
|
782
795
|
const pick = (name, fallback) => style.getPropertyValue(name).trim() || fallback;
|
|
783
|
-
return { sea: pick("--chikyu-flat-sea", "#0b1830"), land: pick("--chikyu-flat-land", "#1d3557"), line: pick("--chikyu-flat-line", "#46628a"), night: pick("--chikyu-flat-night", "rgba(2,
|
|
796
|
+
return { sea: pick("--chikyu-flat-sea", "#0b1830"), land: pick("--chikyu-flat-land", "#1d3557"), line: pick("--chikyu-flat-line", "#46628a"), night: pick("--chikyu-flat-night", "rgba(1,4,14,0.2)"), day: pick("--chikyu-flat-day", "rgba(170,205,255,0.1)"), terminator: pick("--chikyu-flat-terminator", "#ffc46e"), grid: "rgba(150,180,220,0.13)" };
|
|
784
797
|
}
|
|
785
798
|
#projection() {
|
|
786
799
|
const v = this.#view;
|
|
@@ -804,8 +817,9 @@ export class ChikyuFlat extends HTMLElement {
|
|
|
804
817
|
const photo = pictures?.day ? pictures : null;
|
|
805
818
|
// the map is drawn again only when the view, the home or the sun's place (about a quarter of a degree, half a degree over a photo, which costs more) changed
|
|
806
819
|
const c = this.#colours();
|
|
820
|
+
this.#terminatorColour = c.terminator;
|
|
807
821
|
const per = photo ? 2 : 4;
|
|
808
|
-
const key = [v.width, v.height, this.#dpr, v.centerLon.toFixed(3), v.centerLat.toFixed(3), v.zoom.toFixed(3), shade ? Math.round(sun.lon * per) : "x", shade ? Math.round(sun.lat * per) : "x", home ? `${home.lon},${home.lat}` : "", c.sea, c.land, c.line, c.night, photo ? `${photo.day.width}/${photo.night?.width ?? 0}/${this.getAttribute("borders") === "off" ? "x" : "b"}` : "m"].join("|");
|
|
822
|
+
const key = [v.width, v.height, this.#dpr, v.centerLon.toFixed(3), v.centerLat.toFixed(3), v.zoom.toFixed(3), shade ? Math.round(sun.lon * per) : "x", shade ? Math.round(sun.lat * per) : "x", home ? `${home.lon},${home.lat}` : "", c.sea, c.land, c.line, c.night, c.day, c.terminator, photo ? `${photo.day.width}/${photo.night?.width ?? 0}/${this.getAttribute("borders") === "off" ? "x" : "b"}` : "m"].join("|");
|
|
809
823
|
if (key === this.#mapKey)
|
|
810
824
|
return;
|
|
811
825
|
this.#mapKey = key;
|
|
@@ -844,14 +858,33 @@ export class ChikyuFlat extends HTMLElement {
|
|
|
844
858
|
ctx.stroke();
|
|
845
859
|
}
|
|
846
860
|
if (shade) {
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
ctx.fillStyle = c.night;
|
|
850
|
-
for (const radius of photo ? [] : [90, 96, 102, 108]) {
|
|
861
|
+
if (!photo) {
|
|
862
|
+
// the day side a little lighter, and the night side from the sunset line towards midnight in four bands, each darker
|
|
851
863
|
ctx.beginPath();
|
|
852
|
-
path(geoCircle().center(
|
|
864
|
+
path(geoCircle().center([sun.lon, sun.lat]).radius(90).precision(2)());
|
|
865
|
+
ctx.fillStyle = c.day;
|
|
853
866
|
ctx.fill();
|
|
867
|
+
const anti = [wrapLongitude(sun.lon + 180), -sun.lat];
|
|
868
|
+
ctx.fillStyle = c.night;
|
|
869
|
+
for (const radius of [90, 96, 102, 108]) {
|
|
870
|
+
ctx.beginPath();
|
|
871
|
+
path(geoCircle().center(anti).radius(radius).precision(2)());
|
|
872
|
+
ctx.fill();
|
|
873
|
+
}
|
|
854
874
|
}
|
|
875
|
+
// the sunrise and sunset line: 90 degrees from the point under the Sun, drawn as a line (not as the edge of a shape, which would be closed along the map's sides)
|
|
876
|
+
ctx.beginPath();
|
|
877
|
+
path({ type: "LineString", coordinates: geoCircle().center([sun.lon, sun.lat]).radius(90).precision(2)().coordinates[0] });
|
|
878
|
+
ctx.lineJoin = "round";
|
|
879
|
+
ctx.lineWidth = 3.4;
|
|
880
|
+
ctx.strokeStyle = "rgba(0,0,0,.4)";
|
|
881
|
+
ctx.stroke();
|
|
882
|
+
ctx.lineWidth = 1.4;
|
|
883
|
+
ctx.strokeStyle = c.terminator;
|
|
884
|
+
ctx.globalAlpha = photo ? 0.75 : 0.95;
|
|
885
|
+
ctx.stroke();
|
|
886
|
+
ctx.globalAlpha = 1;
|
|
887
|
+
ctx.fillStyle = c.night;
|
|
855
888
|
const at = projectFlat(v, sun.lon, sun.lat);
|
|
856
889
|
const spot = { xs: [], y: at.y, lon: sun.lon, lat: sun.lat };
|
|
857
890
|
for (const x of [at.x, at.x - 360 * pixelsPerDegree(v), at.x + 360 * pixelsPerDegree(v)]) {
|
|
@@ -878,6 +911,7 @@ export class ChikyuFlat extends HTMLElement {
|
|
|
878
911
|
if (spot.xs.length > 0)
|
|
879
912
|
this.#markAt.sun = spot;
|
|
880
913
|
}
|
|
914
|
+
this.#drawAirports(ctx, v);
|
|
881
915
|
if (home) {
|
|
882
916
|
const at = projectFlat(v, home.lon, home.lat);
|
|
883
917
|
const wrap = 360 * pixelsPerDegree(v);
|
|
@@ -902,6 +936,83 @@ export class ChikyuFlat extends HTMLElement {
|
|
|
902
936
|
this.#placeMarkButtons();
|
|
903
937
|
this.#syncLegend();
|
|
904
938
|
}
|
|
939
|
+
/** Ask for the airports, or put them away. The rows are in a chunk of their own, fetched the first time they are asked for. */
|
|
940
|
+
#setAirports(on) {
|
|
941
|
+
if (on === this.#airports)
|
|
942
|
+
return;
|
|
943
|
+
this.#airports = on;
|
|
944
|
+
this.#airportAt = [];
|
|
945
|
+
this.#airportHover = this.#airportShown = null;
|
|
946
|
+
this.#mapKey = "";
|
|
947
|
+
if (on && this.#airportRows === null) {
|
|
948
|
+
void import("./airports-data.js").then((data) => {
|
|
949
|
+
this.#airportRows = data.AIRPORT_ROWS.map(([lon, lat, iata, name, country, tier]) => ({ lon, lat, iata, name, country, tier }));
|
|
950
|
+
this.#mapKey = "";
|
|
951
|
+
this.#request();
|
|
952
|
+
}, () => {
|
|
953
|
+
this.#airportRows = [];
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
/** The airports on the map's own picture: a small white mark with a dark edge, and from zoom 4 the IATA code beside it. The greater airports first, so a world in sight shows the greater ones. */
|
|
958
|
+
#drawAirports(ctx, v) {
|
|
959
|
+
this.#airportAt = [];
|
|
960
|
+
if (!this.#airports || !this.#airportRows)
|
|
961
|
+
return;
|
|
962
|
+
const placed = placeAirports(v, this.#airportRows);
|
|
963
|
+
this.#airportAt = placed;
|
|
964
|
+
const codes = v.zoom >= 4;
|
|
965
|
+
const dark = this.#look === "photo" && this.#photo?.day != null;
|
|
966
|
+
ctx.save();
|
|
967
|
+
ctx.lineJoin = "round";
|
|
968
|
+
ctx.font = "600 10px system-ui, sans-serif";
|
|
969
|
+
ctx.textBaseline = "middle";
|
|
970
|
+
for (const one of placed) {
|
|
971
|
+
ctx.beginPath();
|
|
972
|
+
ctx.arc(one.x, one.y, one.airport.tier === 1 ? 3 : 2.4, 0, Math.PI * 2);
|
|
973
|
+
ctx.fillStyle = "#ffffff";
|
|
974
|
+
ctx.fill();
|
|
975
|
+
ctx.lineWidth = 1.4;
|
|
976
|
+
ctx.strokeStyle = dark ? "rgba(0,0,0,.85)" : "rgba(4,8,18,.9)";
|
|
977
|
+
ctx.stroke();
|
|
978
|
+
if (codes) {
|
|
979
|
+
ctx.lineWidth = 3;
|
|
980
|
+
ctx.strokeStyle = "rgba(4,8,18,.8)";
|
|
981
|
+
ctx.strokeText(one.airport.iata, one.x + 6, one.y);
|
|
982
|
+
ctx.fillStyle = "#ffffff";
|
|
983
|
+
ctx.fillText(one.airport.iata, one.x + 6, one.y);
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
ctx.restore();
|
|
987
|
+
}
|
|
988
|
+
/** The airport drawn nearest to a point, within `reach` pixels. */
|
|
989
|
+
#airportNear(x, y, reach) {
|
|
990
|
+
let best = null;
|
|
991
|
+
let gap = reach * reach;
|
|
992
|
+
for (const one of this.#airportAt) {
|
|
993
|
+
const d = (one.x - x) ** 2 + (one.y - y) ** 2;
|
|
994
|
+
if (d <= gap) {
|
|
995
|
+
gap = d;
|
|
996
|
+
best = one;
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
return best;
|
|
1000
|
+
}
|
|
1001
|
+
/** The name of an airport: its name, code and country, in the page's language. */
|
|
1002
|
+
#airportText(one) {
|
|
1003
|
+
const country = COUNTRIES.features.find((feature) => feature.properties.alpha2 === one.airport.country)?.properties;
|
|
1004
|
+
return airportLine(one.airport, this.language === "ja" ? (country?.ja ?? country?.name ?? null) : (country?.name ?? null), this.language);
|
|
1005
|
+
}
|
|
1006
|
+
/** A press on an airport: its name stays beside it (a finger cannot hover), is read aloud, and the page is told with `chikyu-flat-airport`. */
|
|
1007
|
+
#pressAirport(one) {
|
|
1008
|
+
this.#airportShown = one;
|
|
1009
|
+
this.#placeMarks();
|
|
1010
|
+
const text = this.#airportText(one);
|
|
1011
|
+
if (this.#live)
|
|
1012
|
+
this.#live.textContent = text;
|
|
1013
|
+
const a = one.airport;
|
|
1014
|
+
this.dispatchEvent(new CustomEvent("chikyu-flat-airport", { detail: { iata: a.iata, name: a.name, country: a.country, lon: a.lon, lat: a.lat, tier: a.tier, text, via: "tap" }, bubbles: true, composed: true }));
|
|
1015
|
+
}
|
|
905
1016
|
#home() {
|
|
906
1017
|
const lon = finite(this.getAttribute("home-lon"), Number.NaN);
|
|
907
1018
|
const lat = finite(this.getAttribute("home-lat"), Number.NaN);
|
|
@@ -1260,13 +1371,14 @@ export class ChikyuFlat extends HTMLElement {
|
|
|
1260
1371
|
const named = this.#hover ? null : (this.#markHover ?? this.#markShown);
|
|
1261
1372
|
const spot = named ? this.#markAt[named] : null;
|
|
1262
1373
|
const ref = this.#hover ?? picked;
|
|
1263
|
-
const
|
|
1264
|
-
|
|
1374
|
+
const airport = this.#hover || named ? null : (this.#airportHover ?? this.#airportShown);
|
|
1375
|
+
const where = airport ? { x: airport.x, y: airport.y } : spot && named ? { x: spot.xs[0], y: spot.y } : this.#hover ? (over ?? at) : at;
|
|
1376
|
+
if (!where || (!airport && !spot && (!ref || ref.g.on[ref.i] !== 1))) {
|
|
1265
1377
|
tip.hidden = true;
|
|
1266
1378
|
return;
|
|
1267
1379
|
}
|
|
1268
1380
|
tip.hidden = false;
|
|
1269
|
-
tip.textContent = spot && named ? this.#markText(named) : this.#describe(ref);
|
|
1381
|
+
tip.textContent = airport ? this.#airportText(airport) : spot && named ? this.#markText(named) : this.#describe(ref);
|
|
1270
1382
|
const wide = tip.offsetWidth;
|
|
1271
1383
|
const left = where.x + 14 + wide > this.#view.width ? Math.max(0, where.x - 14 - wide) : where.x + 14;
|
|
1272
1384
|
const top = Math.max(0, Math.min(this.#view.height - tip.offsetHeight, where.y - 10));
|
|
@@ -1363,6 +1475,8 @@ export class ChikyuFlat extends HTMLElement {
|
|
|
1363
1475
|
entries.push({ glyph: "sun", text: say(lang, "keySun") });
|
|
1364
1476
|
if (this.#home())
|
|
1365
1477
|
entries.push({ glyph: "home", text: say(lang, "keyHome") });
|
|
1478
|
+
if (this.#airports)
|
|
1479
|
+
entries.push({ glyph: "airport", text: say(lang, "keyAirport") });
|
|
1366
1480
|
if (shown.length > 0)
|
|
1367
1481
|
entries.push({ glyph: "sat", text: say(lang, byPlane ? "keySatPlane" : "keySatGroup"), colours: byPlane ? PLANE_COLOURS.slice(0, 3) : shown.slice(0, 3).map((g) => g.colour) });
|
|
1368
1482
|
if (this.#faint)
|
|
@@ -1376,7 +1490,7 @@ export class ChikyuFlat extends HTMLElement {
|
|
|
1376
1490
|
entries.push({ glyph: "line", text: say(lang, "trackSunlit"), colours: [colours.sun] }, { glyph: "line", text: say(lang, "trackShadow"), colours: [colours.shadow] });
|
|
1377
1491
|
}
|
|
1378
1492
|
if (shade)
|
|
1379
|
-
entries.push({ glyph: photo ? "night-photo" : "night", text: say(lang, photo ? "keyNightPhoto" : "keyNight") });
|
|
1493
|
+
entries.push({ glyph: "day", text: say(lang, "keyDay") }, { glyph: photo ? "night-photo" : "night", text: say(lang, photo ? "keyNightPhoto" : "keyNight") }, { glyph: "line", text: say(lang, "keyTerminator"), colours: [this.#terminatorColour] });
|
|
1380
1494
|
if (photo)
|
|
1381
1495
|
entries.push({ glyph: "nasa", text: this.#creditText() });
|
|
1382
1496
|
const key = JSON.stringify([lang, open, entries]);
|
|
@@ -1386,6 +1500,7 @@ export class ChikyuFlat extends HTMLElement {
|
|
|
1386
1500
|
const d = box.ownerDocument;
|
|
1387
1501
|
const toggle = d.createElement("button");
|
|
1388
1502
|
toggle.type = "button";
|
|
1503
|
+
toggle.setAttribute("part", "button");
|
|
1389
1504
|
toggle.dataset["act"] = "key";
|
|
1390
1505
|
toggle.setAttribute("aria-expanded", String(open));
|
|
1391
1506
|
toggle.setAttribute("aria-controls", "legend-list");
|
|
@@ -1463,11 +1578,15 @@ export class ChikyuFlat extends HTMLElement {
|
|
|
1463
1578
|
const hovRing = Object.assign(d.createElement("div"), { className: "ring hov", hidden: true });
|
|
1464
1579
|
const tip = Object.assign(d.createElement("div"), { className: "tip", hidden: true });
|
|
1465
1580
|
tip.setAttribute("aria-hidden", "true");
|
|
1581
|
+
tip.setAttribute("part", "tip");
|
|
1466
1582
|
const msg = Object.assign(d.createElement("p"), { className: "msg" });
|
|
1467
1583
|
msg.setAttribute("role", "status");
|
|
1584
|
+
msg.setAttribute("part", "msg");
|
|
1468
1585
|
const key = Object.assign(d.createElement("p"), { className: "key", hidden: true });
|
|
1469
1586
|
key.setAttribute("role", "group");
|
|
1587
|
+
key.setAttribute("part", "key");
|
|
1470
1588
|
const credit = Object.assign(d.createElement("button"), { className: "credit", type: "button", hidden: true });
|
|
1589
|
+
credit.setAttribute("part", "button credit");
|
|
1471
1590
|
credit.append(d.createElement("span"), d.createElement("span"));
|
|
1472
1591
|
credit.children[0].className = "short";
|
|
1473
1592
|
credit.children[1].className = "full";
|
|
@@ -1475,6 +1594,7 @@ export class ChikyuFlat extends HTMLElement {
|
|
|
1475
1594
|
credit.addEventListener("click", () => credit.setAttribute("aria-expanded", String(credit.toggleAttribute("data-open"))));
|
|
1476
1595
|
const legend = Object.assign(d.createElement("div"), { className: "legend", hidden: true });
|
|
1477
1596
|
legend.setAttribute("role", "group");
|
|
1597
|
+
legend.setAttribute("part", "key");
|
|
1478
1598
|
legend.addEventListener("click", this.#onLegend);
|
|
1479
1599
|
const marks = ["sun", "home"].map((mark) => {
|
|
1480
1600
|
const button = Object.assign(d.createElement("button"), { className: "mark", type: "button", hidden: true });
|
|
@@ -1550,7 +1670,7 @@ export class ChikyuFlat extends HTMLElement {
|
|
|
1550
1670
|
this.shadowRoot.querySelector("#help").textContent = say(lang, "help");
|
|
1551
1671
|
bar.setAttribute("role", "toolbar");
|
|
1552
1672
|
bar.setAttribute("aria-label", say(lang, "controls"));
|
|
1553
|
-
const button = (act, label, extra = "") => `<button type="button" data-act="${act}"${extra}>${escape(label)}</button>`;
|
|
1673
|
+
const button = (act, label, extra = "") => `<button type="button" part="button" data-act="${act}"${extra}>${escape(label)}</button>`;
|
|
1554
1674
|
const rows = [];
|
|
1555
1675
|
const first = [];
|
|
1556
1676
|
if (wants.has("centre")) {
|
|
@@ -1558,6 +1678,8 @@ export class ChikyuFlat extends HTMLElement {
|
|
|
1558
1678
|
if (Number.isFinite(finite(this.getAttribute("home-lon"), Number.NaN)))
|
|
1559
1679
|
first.push(button("home", say(lang, "myPlace"), ` aria-label="${escape(say(lang, "centreHome"))}" aria-pressed="false"`));
|
|
1560
1680
|
}
|
|
1681
|
+
if (wants.has("airports"))
|
|
1682
|
+
first.push(button("airports", say(lang, "airports"), ` aria-pressed="false"`));
|
|
1561
1683
|
// the look's own pair of buttons, beside the centre buttons and not at the far end of the row (a page's own buttons often sit there): not among the defaults, so a page that has not asked for it sees no new button
|
|
1562
1684
|
if (wants.has("look"))
|
|
1563
1685
|
first.push(`<span class="pair" role="group" aria-label="${escape(say(lang, "lookGroup"))}">${button("look-map", say(lang, "lookMap"), ` aria-pressed="false"`)}${button("look-photo", say(lang, "lookPhoto"), ` aria-pressed="false"`)}</span>`);
|
|
@@ -1578,13 +1700,13 @@ export class ChikyuFlat extends HTMLElement {
|
|
|
1578
1700
|
const g = one[0];
|
|
1579
1701
|
const chips = [button("plane", say(lang, "all"), ` class="chip" data-plane="" aria-pressed="false"`)];
|
|
1580
1702
|
for (const plane of g.clusters.planes)
|
|
1581
|
-
chips.push(`<button type="button" class="chip" data-act="plane" data-plane="${plane.id}" data-i="${plane.index}" aria-pressed="false" aria-label="${escape(say(lang, "planeChip", { id: plane.id, count: plane.count }))}"><span class="swatch"></span>${escape(plane.id)} <span class="n">${plane.count}</span></button>`);
|
|
1703
|
+
chips.push(`<button type="button" part="button" class="chip" data-act="plane" data-plane="${plane.id}" data-i="${plane.index}" aria-pressed="false" aria-label="${escape(say(lang, "planeChip", { id: plane.id, count: plane.count }))}"><span class="swatch"></span>${escape(plane.id)} <span class="n">${plane.count}</span></button>`);
|
|
1582
1704
|
rows.push(`<div class="row chips" role="group" aria-label="${escape(say(lang, "planesFilter"))}">${chips.join("")}</div>`);
|
|
1583
1705
|
}
|
|
1584
1706
|
else if (groups === "groups") {
|
|
1585
|
-
const chips = [`<button type="button" class="chip" data-act="group" data-group="*" aria-pressed="false">${escape(say(lang, "all"))}</button>`];
|
|
1707
|
+
const chips = [`<button type="button" part="button" class="chip" data-act="group" data-group="*" aria-pressed="false">${escape(say(lang, "all"))}</button>`];
|
|
1586
1708
|
for (const g of this.#groups.values())
|
|
1587
|
-
chips.push(`<button type="button" class="chip" data-act="group" data-group="${escape(g.id)}" aria-pressed="false"><span class="swatch"></span>${escape(lang === "ja" ? g.labelJa : g.label)} <span class="n">${g.n.toLocaleString(lang)}</span></button>`);
|
|
1709
|
+
chips.push(`<button type="button" part="button" class="chip" data-act="group" data-group="${escape(g.id)}" aria-pressed="false"><span class="swatch"></span>${escape(lang === "ja" ? g.labelJa : g.label)} <span class="n">${g.n.toLocaleString(lang)}</span></button>`);
|
|
1588
1710
|
rows.push(`<div class="row chips" role="group" aria-label="${escape(say(lang, "groupsFilter"))}">${chips.join("")}</div>`);
|
|
1589
1711
|
}
|
|
1590
1712
|
}
|
|
@@ -1620,6 +1742,7 @@ export class ChikyuFlat extends HTMLElement {
|
|
|
1620
1742
|
set('[data-act="home"]', Number.isFinite(home.lon) && Math.abs(wrapLongitude(this.#view.centerLon - home.lon)) < 0.5);
|
|
1621
1743
|
set('[data-act="footprint"]', this.#footprint);
|
|
1622
1744
|
set('[data-act="track"]', this.#track);
|
|
1745
|
+
set('[data-act="airports"]', this.#airports);
|
|
1623
1746
|
set('[data-act="look-map"]', this.#look === "map");
|
|
1624
1747
|
set('[data-act="look-photo"]', this.#look === "photo");
|
|
1625
1748
|
const shown = this.#shownGroups();
|
|
@@ -1672,6 +1795,9 @@ export class ChikyuFlat extends HTMLElement {
|
|
|
1672
1795
|
// the attribute is the look: the page that set the controls sees the change as it sees any other
|
|
1673
1796
|
this.setAttribute("look", act === "look-photo" ? "photo" : "map");
|
|
1674
1797
|
}
|
|
1798
|
+
else if (act === "airports") {
|
|
1799
|
+
this.toggleAttribute("airports");
|
|
1800
|
+
}
|
|
1675
1801
|
else if (act === "track") {
|
|
1676
1802
|
this.#track = !this.#track;
|
|
1677
1803
|
this.#trackKey = "";
|
|
@@ -1863,9 +1989,17 @@ export class ChikyuFlat extends HTMLElement {
|
|
|
1863
1989
|
this.#pressMark(mark, "tap");
|
|
1864
1990
|
return;
|
|
1865
1991
|
}
|
|
1866
|
-
|
|
1992
|
+
const airport = hit ? null : this.#airportNear(at.x, at.y, event.pointerType === "touch" ? 20 : 9);
|
|
1993
|
+
if (airport) {
|
|
1994
|
+
this.#markShown = null;
|
|
1995
|
+
this.#pressAirport(airport);
|
|
1996
|
+
return;
|
|
1997
|
+
}
|
|
1998
|
+
// a tap anywhere else puts a pressed mark's or airport's name away
|
|
1867
1999
|
this.#markShown = null;
|
|
1868
2000
|
this.#markHover = null;
|
|
2001
|
+
this.#airportShown = null;
|
|
2002
|
+
this.#airportHover = null;
|
|
1869
2003
|
this.#placeMarks();
|
|
1870
2004
|
this.#choose(hit, "tap");
|
|
1871
2005
|
}
|
|
@@ -1881,10 +2015,11 @@ export class ChikyuFlat extends HTMLElement {
|
|
|
1881
2015
|
}
|
|
1882
2016
|
};
|
|
1883
2017
|
#onLeave = (event) => {
|
|
1884
|
-
if (event.pointerType !== "mouse" || (this.#hover === null && this.#markHover === null))
|
|
2018
|
+
if (event.pointerType !== "mouse" || (this.#hover === null && this.#markHover === null && this.#airportHover === null))
|
|
1885
2019
|
return;
|
|
1886
2020
|
this.#hover = null;
|
|
1887
2021
|
this.#markHover = null;
|
|
2022
|
+
this.#airportHover = null;
|
|
1888
2023
|
if (this.#dotCanvas)
|
|
1889
2024
|
this.#dotCanvas.style.cursor = "";
|
|
1890
2025
|
this.#placeMarks();
|
|
@@ -1893,12 +2028,14 @@ export class ChikyuFlat extends HTMLElement {
|
|
|
1893
2028
|
const near = this.#hit(x, y, 8);
|
|
1894
2029
|
const mark = this.#markOver(near, x, y, 11);
|
|
1895
2030
|
const hit = mark ? null : near;
|
|
2031
|
+
const airport = hit || mark ? null : this.#airportNear(x, y, 8);
|
|
1896
2032
|
if (this.#dotCanvas)
|
|
1897
|
-
this.#dotCanvas.style.cursor = mark ? "pointer" : "";
|
|
1898
|
-
if (sameRef(hit, this.#hover) && mark === this.#markHover)
|
|
2033
|
+
this.#dotCanvas.style.cursor = mark || airport ? "pointer" : "";
|
|
2034
|
+
if (sameRef(hit, this.#hover) && mark === this.#markHover && airport?.airport === this.#airportHover?.airport)
|
|
1899
2035
|
return;
|
|
1900
2036
|
this.#hover = hit;
|
|
1901
2037
|
this.#markHover = mark;
|
|
2038
|
+
this.#airportHover = airport;
|
|
1902
2039
|
this.#placeMarks();
|
|
1903
2040
|
if (hit)
|
|
1904
2041
|
this.#pick(hit, "hover");
|
|
@@ -1924,8 +2061,9 @@ export class ChikyuFlat extends HTMLElement {
|
|
|
1924
2061
|
return;
|
|
1925
2062
|
}
|
|
1926
2063
|
if (key === "Escape") {
|
|
1927
|
-
if (this.#markShown) {
|
|
2064
|
+
if (this.#markShown || this.#airportShown) {
|
|
1928
2065
|
this.#markShown = null;
|
|
2066
|
+
this.#airportShown = null;
|
|
1929
2067
|
this.#placeMarks();
|
|
1930
2068
|
}
|
|
1931
2069
|
if (this.#cursor || this.#selected) {
|