@johnmorrisdotca/chikyu-earth 0.66.0 → 0.67.0

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.
@@ -6,6 +6,8 @@ import { adoptStyles } from "../adopt.js";
6
6
  import { footprintAngle, BEAM_ELEVATION } from "../beam/geometry.js";
7
7
  import { orbitShape } from "../catalogue/orbit.js";
8
8
  import { COUNTRIES } from "../countries.js";
9
+ import { creditLine } from "../data-door.js";
10
+ import { ownCredit } from "../door/own.js";
9
11
  import { groundTrack } from "../passes/passes.js";
10
12
  import { subsolarPoint, greenwichSidereal } from "../realistic/sun.js";
11
13
  import { SATELLITE_GROUPS } from "../satellites/catalogue.js";
@@ -17,6 +19,8 @@ import { GROUP_COLOURS, PLANE_COLOURS, SPARE_COLOUR, TRACK_SHADOW, TRACK_SUNLIT
17
19
  import { clusterPlanes, groupFacts } from "./facts.js";
18
20
  import { FLATTENED, MAX_ZOOM, clampView, pixelsPerDegree, projectFlat, wrapLongitude, zoomAbout } from "./geometry.js";
19
21
  import { trackStateOfScene } from "./track-state.js";
22
+ import { pointText, placeOver } from "./marks.js";
23
+ import { PhotoPictures, paintPhoto, readLook } from "./photo.js";
20
24
  import { say } from "./words.js";
21
25
  const RAD = Math.PI / 180;
22
26
  /** The most satellites whose footprints are drawn at once when none is chosen. */
@@ -70,6 +74,9 @@ const CSS = `
70
74
  .chips>*{flex:none}
71
75
  @container (min-width:600px){.chips{flex-wrap:wrap;overflow:visible}}
72
76
  .gap{flex:1 1 0}
77
+ .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}
73
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}
74
81
  button[aria-pressed="true"]{background:color-mix(in srgb,currentColor 14%,transparent);border-color:currentColor}
75
82
  button:disabled{opacity:.45;cursor:default}
@@ -91,6 +98,33 @@ canvas{position:absolute;inset:0;width:100%;height:100%;display:block}
91
98
  .key[hidden]{display:none}
92
99
  .key span{display:inline-flex;align-items:center;gap:6px}
93
100
  .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
+ 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
+ button.mark[hidden]{display:none}
103
+ button.mark:focus-visible{outline:3px solid #6cd0ff;outline-offset:0}
104
+ .legend{font-size:.85em;line-height:1.3;padding-left:var(--chikyu-flat-key-inset,0)}
105
+ .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}}
108
+ .legend ul{list-style:none;margin:6px 0 0;padding:0;display:flex;flex-wrap:wrap;gap:6px 16px}
109
+ .legend li{display:inline-flex;align-items:center;gap:6px}
110
+ .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)}
111
+ .g i{display:block;width:7px;height:7px;border-radius:50%;background:var(--c,#9aa5b1)}
112
+ .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
+ .g.home::before{content:"";width:8px;height:8px;background:#fff;box-shadow:0 0 0 2px #0b1830;transform:rotate(45deg)}
114
+ .g.sat i{width:6px;height:6px}
115
+ .g.faint::before{content:"";width:7px;height:7px;border-radius:50%;background:#9aa5b1;opacity:.45}
116
+ .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
+ .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
+ .g.line i{width:20px;height:0;border-radius:2px;background:none;border-top:3px solid var(--c)}
119
+ .g.nasa::before{content:"NASA";font-size:.6em;letter-spacing:.04em;color:#fff}
120
+ .g.night{background:linear-gradient(90deg,#2a4a73,#07101f)}
121
+ .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
+ 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
+ button.credit .full,button.credit[data-open] .short{display:none}
124
+ button.credit[data-open] .full{display:inline}
125
+ @container (min-width:600px){button.credit{cursor:default}button.credit .short{display:none}button.credit .full{display:inline}}
126
+ @media (pointer:coarse){button.credit{min-height:28px;padding:4px 10px}}
127
+ .credit[hidden]{display:none}
94
128
  .msg{position:absolute;inset:0;display:grid;place-items:center;margin:0;padding:12px;text-align:center;color:#cfe0f5;pointer-events:none}
95
129
  .msg:empty{display:none}
96
130
  .sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
@@ -102,11 +136,13 @@ canvas{position:absolute;inset:0;width:100%;height:100%;display:block}
102
136
  * Attributes: `center` (the longitude in the middle, degrees; 0, Greenwich, by default; the map wraps round the date line), `home-lon` and `home-lat` (the reader's place: a marker, and the "My place" button, which appear only when given; the element never asks the browser for a place),
103
137
  * `group` (which groups to show: `all`, one id, or several with commas), `off` (groups that are loaded but start off when `group` names none, such as `starlink`: the filter chip turns one on), `colour-by` (`group`, or `plane` to colour by orbital plane), `plane` (a plane letter: show that plane only), `footprint` and `track` (draw the coverage circle and the ground track, which is amber in sunlight and blue in the Earth's shadow, a cylinder, with a key: `--chikyu-flat-track-sun` and `--chikyu-flat-track-shadow` change the colours; the footprint is of the chosen satellite, or of every one shown when there are 80 or fewer),
104
138
  * `paused` (hold the clock and keep the speed; nothing is drawn while it is held), `trails` (`off` for no streaks at a fast clock), `footprint-elevation` (degrees above the horizon the circle is drawn for; 25 like the 3D beam), `selected` (a NORAD number: the chosen satellite), `time` (`now` or an ISO date; live when absent), `speed` (1 is real time, 0 holds, 86400 is a day a second, negative runs backwards), `estimate-far` (`steady` keeps each satellite's usual orbit beyond 30 days from its elements), `shade` (`off` for no night),
105
- * `dot-size` (pixels), `controls` (`none`, or any of `centre zoom footprint track chips`: the built-in buttons and filter chips shown; all by default) and `lang` (`en` or `ja`; the page's language by default).
139
+ * `dot-size` (pixels), `controls` (`none`, or any of `centre zoom footprint track chips key look`: the built-in buttons, filter chips, key and Map / Photo pair shown; all but `look` by default) and `lang` (`en` or `ja`; the page's language by default).
140
+ * `look` is `map` (the drawn map, the default) or `photo` (NASA's picture of the Earth, with the night side's city lights; `borders="off"` leaves out the country lines, `texture-base` and `max-texture` are as on the realistic Earth; the pictures are fetched only while it is on, and `lookState` says how it stands).
141
+ * The key under the map names every mark the map draws (`keyOpen` folds it open or shut: open on a wide map, shut on a phone until asked), and the yellow dot (the Sun overhead) and the white diamond (My place) name themselves, with where, when pointed at, pressed or reached with the Tab key.
106
142
  *
107
143
  * 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 }`),
108
- * `chikyu-flat-planes` (the planes were worked out: `{ planes }`), `chikyu-flat-view` (the reader panned or zoomed: `{ center, zoom }`) and `chikyu-timechange` (`{ time, running }`, at most four a second while time runs).
109
- * Style it with the custom properties `--chikyu-flat-sea`, `--chikyu-flat-land`, `--chikyu-flat-line`, `--chikyu-flat-night`, `--chikyu-flat-aspect`, `--chikyu-flat-aspect-narrow` and `--chikyu-flat-radius`.
144
+ * `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`.
110
146
  *
111
147
  * @example
112
148
  * ```ts no-run
@@ -124,7 +160,7 @@ canvas{position:absolute;inset:0;width:100%;height:100%;display:block}
124
160
  * ```
125
161
  */
126
162
  export class ChikyuFlat extends HTMLElement {
127
- 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"];
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"];
128
164
  #groups = new Map();
129
165
  #index = new Map();
130
166
  #shown = null;
@@ -159,6 +195,20 @@ export class ChikyuFlat extends HTMLElement {
159
195
  #viewSent = "";
160
196
  #announced = -Infinity;
161
197
  #mapKey = "";
198
+ #look = "map";
199
+ #photo = null;
200
+ #photoFailed = false;
201
+ #lookSent = "";
202
+ #markAt = { sun: null, home: null };
203
+ #markHover = null;
204
+ #markShown = null;
205
+ #markNames = new Map();
206
+ #markButtons = { sun: undefined, home: undefined };
207
+ #legend;
208
+ #legendKey = "";
209
+ #legendOpen = null;
210
+ #faint = false;
211
+ #credit;
162
212
  #trackKey = "";
163
213
  #trackLines = null;
164
214
  #key;
@@ -349,6 +399,19 @@ export class ChikyuFlat extends HTMLElement {
349
399
  get language() {
350
400
  return (this.getAttribute("lang") ?? this.ownerDocument.documentElement.lang ?? "en").toLowerCase().startsWith("ja") ? "ja" : "en";
351
401
  }
402
+ /** The look of the map: `map`, the drawn map of countries (the default), or `photo`, NASA's picture of the Earth with the night side's city lights. The `look` attribute; the pictures are fetched only while the look is `photo`. */
403
+ get look() {
404
+ return this.#look;
405
+ }
406
+ set look(value) {
407
+ this.setAttribute("look", readLook(value));
408
+ }
409
+ /** How the look stands: `map` (the drawn map is chosen), `loading` (the photo is chosen and its picture is on its way, the drawn map shows meanwhile), `photo` (the photo is shown) or `failed` (the picture could not be fetched, the drawn map shows). `chikyu-flat-look` tells the page when it changes. */
410
+ get lookState() {
411
+ if (this.#look === "map")
412
+ return "map";
413
+ return this.#photoFailed ? "failed" : this.#photo?.day ? "photo" : "loading";
414
+ }
352
415
  /** Counters for a test or a page: draws of the dots, draws of the map, the dots drawn at the last draw, the milliseconds the last draw and the slowest took, and the canvases' size in pixels. */
353
416
  get stats() {
354
417
  const canvases = [this.#mapCanvas, this.#dotCanvas].filter((c) => c !== undefined).map((c) => ({ width: c.width, height: c.height }));
@@ -402,6 +465,9 @@ export class ChikyuFlat extends HTMLElement {
402
465
  this.#sizer = undefined;
403
466
  this.#watcher = undefined;
404
467
  document.removeEventListener("visibilitychange", this.#onVisibility);
468
+ // the pictures are let go with the element, and fetched again if it comes back
469
+ this.#photo?.dispose();
470
+ this.#photo = null;
405
471
  }
406
472
  attributeChangedCallback(name) {
407
473
  if (!this.#connected)
@@ -409,6 +475,10 @@ export class ChikyuFlat extends HTMLElement {
409
475
  this.#read(name);
410
476
  if (name === "selected" || name === "footprint-elevation")
411
477
  this.#trackKey = "";
478
+ if (name === "lang") {
479
+ this.#showCredit();
480
+ this.#placeMarkButtons();
481
+ }
412
482
  if (name === "lang" || name === "controls" || name === "group" || name === "colour-by" || name === "color-by" || name === "home-lon" || name === "home-lat" || name === "plane")
413
483
  this.#buildBar();
414
484
  this.#sync();
@@ -474,9 +544,90 @@ export class ChikyuFlat extends HTMLElement {
474
544
  g.sats.estimateFar = estimateFarOf(value);
475
545
  else if (name === "elements-src")
476
546
  this.#load();
477
- else if (name === "shade" || name === "dot-size")
547
+ else if (name === "look")
548
+ this.#setLook(readLook(value));
549
+ else if (name === "texture-base" && this.#photo) {
550
+ this.#photo.dispose();
551
+ this.#photo = this.#makePhoto();
552
+ this.#mapKey = "";
553
+ }
554
+ else if (name === "shade" || name === "dot-size" || name === "borders" || name === "max-texture")
478
555
  this.#mapKey = "";
479
556
  }
557
+ /** 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
+ #textureBase() {
559
+ const base = this.getAttribute("texture-base") ?? new URL("../textures/", import.meta.url).href;
560
+ return base.endsWith("/") ? base : `${base}/`;
561
+ }
562
+ /** 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. */
563
+ #textureCap() {
564
+ const given = Number(this.getAttribute("max-texture"));
565
+ const memory = navigator.deviceMemory;
566
+ const cap = Number.isFinite(given) && given > 0 ? Math.min(given, 4096) : 4096;
567
+ return memory !== undefined && memory <= 2 ? Math.min(cap, 2048) : cap;
568
+ }
569
+ #makePhoto() {
570
+ const again = () => {
571
+ this.#mapKey = "";
572
+ this.#request();
573
+ this.#announceLook();
574
+ };
575
+ return new PhotoPictures({
576
+ base: () => this.#textureBase(),
577
+ cap: () => this.#textureCap(),
578
+ changed: again,
579
+ failed: () => {
580
+ this.#photoFailed = true;
581
+ again();
582
+ },
583
+ });
584
+ }
585
+ #setLook(look) {
586
+ if (look === this.#look && (look === "map" || this.#photo))
587
+ return;
588
+ this.#look = look;
589
+ this.#photoFailed = false;
590
+ this.#photo?.dispose();
591
+ this.#photo = look === "photo" ? this.#makePhoto() : null;
592
+ this.#mapKey = "";
593
+ this.#showCredit();
594
+ this.#announceLook();
595
+ }
596
+ /** `chikyu-flat-look`, when the look or how it stands changes. */
597
+ #announceLook() {
598
+ const state = this.lookState;
599
+ const key = `${this.#look}/${state}`;
600
+ this.#showCredit();
601
+ if (key === this.#lookSent)
602
+ return;
603
+ const first = this.#lookSent === "";
604
+ this.#lookSent = key;
605
+ if (!first)
606
+ this.dispatchEvent(new CustomEvent("chikyu-flat-look", { detail: { look: this.#look, state }, bubbles: true, composed: true }));
607
+ }
608
+ /** NASA's credit, at the map's bottom edge while the photo is shown: the whole line on a wide map, "Earth: NASA" on a narrow one with the whole line a tap away (and in the key). */
609
+ #showCredit() {
610
+ const credit = this.#credit;
611
+ if (!credit)
612
+ return;
613
+ const on = this.#look === "photo" && this.#photo?.day != null;
614
+ credit.hidden = !on;
615
+ if (!on)
616
+ return;
617
+ const lang = this.language;
618
+ const line = this.#creditText();
619
+ const [short, full] = credit.children;
620
+ if (full.textContent !== line)
621
+ full.textContent = line;
622
+ short.textContent = say(lang, "creditShort");
623
+ credit.setAttribute("aria-label", line);
624
+ credit.title = line;
625
+ credit.lang = lang;
626
+ }
627
+ /** The whole credit line of the pictures, in the page's language. */
628
+ #creditText() {
629
+ return creditLine([ownCredit("chikyu-pictures", 1)], this.language);
630
+ }
480
631
  #readClock() {
481
632
  this.#advance(performance.now());
482
633
  this.#mode = readTime(this.getAttribute("time"));
@@ -617,6 +768,7 @@ export class ChikyuFlat extends HTMLElement {
617
768
  return;
618
769
  this.#dpr = dpr;
619
770
  this.#view = clampView({ ...this.#view, width, height });
771
+ this.#syncLegend();
620
772
  for (const canvas of [this.#mapCanvas, this.#dotCanvas]) {
621
773
  if (!canvas)
622
774
  continue;
@@ -647,12 +799,17 @@ export class ChikyuFlat extends HTMLElement {
647
799
  const sun = subsolarPoint(ms);
648
800
  const shade = this.getAttribute("shade") !== "off";
649
801
  const home = this.#home();
650
- // the map is drawn again only when the view, the home or the sun's place (about a quarter of a degree) changed
802
+ const pictures = this.#look === "photo" ? this.#photo : null;
803
+ pictures?.want(360 * pixelsPerDegree(v) * this.#dpr);
804
+ const photo = pictures?.day ? pictures : null;
805
+ // 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
651
806
  const c = this.#colours();
652
- 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 * 4) : "x", shade ? Math.round(sun.lat * 4) : "x", home ? `${home.lon},${home.lat}` : "", c.sea, c.land, c.line, c.night].join("|");
807
+ 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("|");
653
809
  if (key === this.#mapKey)
654
810
  return;
655
811
  this.#mapKey = key;
812
+ this.#markAt = { sun: null, home: null };
656
813
  this.#counts.mapDraws += 1;
657
814
  const ctx = canvas.getContext("2d", { willReadFrequently: true });
658
815
  if (!ctx)
@@ -662,47 +819,73 @@ export class ChikyuFlat extends HTMLElement {
662
819
  ctx.fillRect(0, 0, v.width, v.height);
663
820
  const projection = this.#projection();
664
821
  const path = geoPath(projection, ctx);
665
- ctx.beginPath();
666
- path(geoGraticule10());
667
- ctx.strokeStyle = c.grid;
668
- ctx.lineWidth = 1;
669
- ctx.stroke();
670
- ctx.beginPath();
671
- path(COUNTRIES);
672
- ctx.fillStyle = c.land;
673
- ctx.fill();
674
- ctx.strokeStyle = c.line;
675
- ctx.lineWidth = 0.6;
676
- ctx.stroke();
822
+ if (photo) {
823
+ // NASA's picture on the map, the borders thin and pale on it, then the night (the darkening and the city lights) over both
824
+ paintPhoto(ctx, v, photo, shade ? sun : null, this.getAttribute("borders") === "off" ? null : () => {
825
+ ctx.beginPath();
826
+ path(COUNTRIES);
827
+ ctx.strokeStyle = "rgba(255,255,255,0.32)";
828
+ ctx.lineWidth = 0.6;
829
+ ctx.stroke();
830
+ });
831
+ }
832
+ else {
833
+ ctx.beginPath();
834
+ path(geoGraticule10());
835
+ ctx.strokeStyle = c.grid;
836
+ ctx.lineWidth = 1;
837
+ ctx.stroke();
838
+ ctx.beginPath();
839
+ path(COUNTRIES);
840
+ ctx.fillStyle = c.land;
841
+ ctx.fill();
842
+ ctx.strokeStyle = c.line;
843
+ ctx.lineWidth = 0.6;
844
+ ctx.stroke();
845
+ }
677
846
  if (shade) {
678
847
  // the night side: four bands from the sunset line towards midnight, each a little darker
679
848
  const anti = [wrapLongitude(sun.lon + 180), -sun.lat];
680
849
  ctx.fillStyle = c.night;
681
- for (const radius of [90, 96, 102, 108]) {
850
+ for (const radius of photo ? [] : [90, 96, 102, 108]) {
682
851
  ctx.beginPath();
683
852
  path(geoCircle().center(anti).radius(radius).precision(2)());
684
853
  ctx.fill();
685
854
  }
686
855
  const at = projectFlat(v, sun.lon, sun.lat);
856
+ const spot = { xs: [], y: at.y, lon: sun.lon, lat: sun.lat };
687
857
  for (const x of [at.x, at.x - 360 * pixelsPerDegree(v), at.x + 360 * pixelsPerDegree(v)]) {
688
858
  if (x < -8 || x > v.width + 8)
689
859
  continue;
860
+ spot.xs.push(x);
690
861
  ctx.beginPath();
691
862
  ctx.arc(x, at.y, 5, 0, Math.PI * 2);
692
863
  ctx.fillStyle = "#ffd54f";
693
864
  ctx.fill();
694
- ctx.lineWidth = 1;
695
- ctx.strokeStyle = "rgba(0,0,0,.5)";
865
+ // over a photo the dot has a dark edge and a pale ring round it, so it reads on cloud, desert and sea
866
+ ctx.lineWidth = photo ? 2 : 1;
867
+ ctx.strokeStyle = photo ? "rgba(0,0,0,.75)" : "rgba(0,0,0,.5)";
696
868
  ctx.stroke();
869
+ if (photo) {
870
+ ctx.beginPath();
871
+ ctx.arc(x, at.y, 6.8, 0, Math.PI * 2);
872
+ ctx.lineWidth = 1;
873
+ ctx.strokeStyle = "rgba(255,255,255,.85)";
874
+ ctx.stroke();
875
+ }
697
876
  ctx.fillStyle = c.night;
698
877
  }
878
+ if (spot.xs.length > 0)
879
+ this.#markAt.sun = spot;
699
880
  }
700
881
  if (home) {
701
882
  const at = projectFlat(v, home.lon, home.lat);
702
883
  const wrap = 360 * pixelsPerDegree(v);
884
+ const spot = { xs: [], y: at.y, lon: home.lon, lat: home.lat };
703
885
  for (const x of [at.x, at.x - wrap, at.x + wrap]) {
704
886
  if (x < -10 || x > v.width + 10)
705
887
  continue;
888
+ spot.xs.push(x);
706
889
  ctx.save();
707
890
  ctx.translate(x, at.y);
708
891
  ctx.rotate(Math.PI / 4);
@@ -713,7 +896,11 @@ export class ChikyuFlat extends HTMLElement {
713
896
  ctx.fillRect(-4.5, -4.5, 9, 9);
714
897
  ctx.restore();
715
898
  }
899
+ if (spot.xs.length > 0)
900
+ this.#markAt.home = spot;
716
901
  }
902
+ this.#placeMarkButtons();
903
+ this.#syncLegend();
717
904
  }
718
905
  #home() {
719
906
  const lon = finite(this.getAttribute("home-lon"), Number.NaN);
@@ -870,27 +1057,38 @@ export class ChikyuFlat extends HTMLElement {
870
1057
  }
871
1058
  ctx.globalAlpha = 1;
872
1059
  }
1060
+ // over a photo each dot has a dark rim, so it reads on white cloud and on pale desert alike
1061
+ const rim = this.#look === "photo" && this.#photo?.day != null;
873
1062
  for (const [key, list] of buckets) {
874
1063
  if (list.length === 0)
875
1064
  continue;
876
1065
  const faint = key.endsWith("~");
877
- ctx.fillStyle = faint ? key.slice(0, -1) : key;
878
- ctx.globalAlpha = faint ? 0.45 : 1;
879
- if (radius <= 1.7) {
880
- const side = radius * 2;
881
- for (let j = 0; j < list.length; j += 2)
882
- ctx.fillRect(list[j] - radius, list[j + 1] - radius, side, side);
883
- }
884
- else {
885
- ctx.beginPath();
886
- for (let j = 0; j < list.length; j += 2) {
887
- ctx.moveTo(list[j] + radius, list[j + 1]);
888
- ctx.arc(list[j], list[j + 1], radius, 0, Math.PI * 2);
1066
+ for (const pass of rim ? [true, false] : [false]) {
1067
+ const grown = pass ? radius + 1 : radius;
1068
+ ctx.fillStyle = pass ? "rgba(4,8,18,0.7)" : faint ? key.slice(0, -1) : key;
1069
+ ctx.globalAlpha = faint ? 0.45 : 1;
1070
+ if (grown <= 1.7) {
1071
+ const side = grown * 2;
1072
+ for (let j = 0; j < list.length; j += 2)
1073
+ ctx.fillRect(list[j] - grown, list[j + 1] - grown, side, side);
1074
+ }
1075
+ else {
1076
+ ctx.beginPath();
1077
+ for (let j = 0; j < list.length; j += 2) {
1078
+ ctx.moveTo(list[j] + grown, list[j + 1]);
1079
+ ctx.arc(list[j], list[j + 1], grown, 0, Math.PI * 2);
1080
+ }
1081
+ ctx.fill();
889
1082
  }
890
- ctx.fill();
891
1083
  }
892
1084
  }
893
1085
  ctx.globalAlpha = 1;
1086
+ // the key names the faint dots (old orbit data) only while there are some
1087
+ const faint = [...buckets].some(([colour, list]) => list.length > 0 && colour.endsWith("~"));
1088
+ if (faint !== this.#faint) {
1089
+ this.#faint = faint;
1090
+ this.#syncLegend();
1091
+ }
894
1092
  this.#counts.draws += 1;
895
1093
  this.#counts.dots = dots;
896
1094
  this.#placeMarks();
@@ -926,7 +1124,13 @@ export class ChikyuFlat extends HTMLElement {
926
1124
  path(geoCircle().center([g.lon[i], g.lat[i]]).radius(angle).precision(3)());
927
1125
  ctx.fillStyle = "rgba(255,255,255,0.07)";
928
1126
  ctx.fill();
929
- ctx.strokeStyle = "rgba(255,255,255,0.45)";
1127
+ const onPhoto = this.#look === "photo" && this.#photo?.day != null;
1128
+ if (onPhoto) {
1129
+ ctx.strokeStyle = "rgba(4,8,18,0.55)";
1130
+ ctx.lineWidth = 3;
1131
+ ctx.stroke();
1132
+ }
1133
+ ctx.strokeStyle = onPhoto ? "rgba(255,255,255,0.8)" : "rgba(255,255,255,0.45)";
930
1134
  ctx.lineWidth = 1;
931
1135
  ctx.stroke();
932
1136
  };
@@ -979,10 +1183,11 @@ export class ChikyuFlat extends HTMLElement {
979
1183
  return { sun: style.getPropertyValue("--chikyu-flat-track-sun").trim() || TRACK_SUNLIT, shadow: style.getPropertyValue("--chikyu-flat-track-shadow").trim() || TRACK_SHADOW };
980
1184
  }
981
1185
  /** The key to the track's two colours, shown while the track is. It changes only when the track appears or goes, or the language does. */
982
- #showKey(on) {
1186
+ #showKey(wanted) {
983
1187
  const key = this.#key;
984
1188
  if (!key)
985
1189
  return;
1190
+ const on = wanted && !(this.#wants().has("key") && this.#legendIsOpen());
986
1191
  if (key.hidden === !on && (!on || key.lang === this.language))
987
1192
  return;
988
1193
  key.hidden = !on;
@@ -1051,19 +1256,174 @@ export class ChikyuFlat extends HTMLElement {
1051
1256
  const tip = this.#tip;
1052
1257
  if (!tip)
1053
1258
  return;
1259
+ // a satellite pointed at is named first, then a mark pointed at, then a mark pressed or reached by the keyboard, then the satellite chosen
1260
+ const named = this.#hover ? null : (this.#markHover ?? this.#markShown);
1261
+ const spot = named ? this.#markAt[named] : null;
1054
1262
  const ref = this.#hover ?? picked;
1055
- const where = this.#hover ? (over ?? at) : at;
1056
- if (!ref || !where || ref.g.on[ref.i] !== 1) {
1263
+ const where = spot && named ? { x: spot.xs[0], y: spot.y } : this.#hover ? (over ?? at) : at;
1264
+ if (!where || (!spot && (!ref || ref.g.on[ref.i] !== 1))) {
1057
1265
  tip.hidden = true;
1058
1266
  return;
1059
1267
  }
1060
1268
  tip.hidden = false;
1061
- tip.textContent = this.#describe(ref);
1269
+ tip.textContent = spot && named ? this.#markText(named) : this.#describe(ref);
1062
1270
  const wide = tip.offsetWidth;
1063
1271
  const left = where.x + 14 + wide > this.#view.width ? Math.max(0, where.x - 14 - wide) : where.x + 14;
1064
1272
  const top = Math.max(0, Math.min(this.#view.height - tip.offsetHeight, where.y - 10));
1065
1273
  tip.style.transform = `translate(${left.toFixed(1)}px,${top.toFixed(1)}px)`;
1066
1274
  }
1275
+ // --- the marks that name themselves ------------------------------------------------------------------------------------------------------------
1276
+ /** What a mark says about itself, in the page's language: what it is, what it is over, and where. Worked out once for each place (to a degree). */
1277
+ #markText(mark) {
1278
+ const spot = this.#markAt[mark];
1279
+ if (!spot)
1280
+ return "";
1281
+ const lang = this.language;
1282
+ const id = `${mark}|${lang}|${Math.round(spot.lon)}|${Math.round(spot.lat)}`;
1283
+ let text = this.#markNames.get(id);
1284
+ if (text === undefined) {
1285
+ const what = say(lang, mark === "sun" ? "sunMark" : "homeMark");
1286
+ const point = pointText(spot.lon, spot.lat, lang);
1287
+ const place = placeOver(spot.lon, spot.lat, lang);
1288
+ text = place ? say(lang, mark === "sun" ? "sunOver" : "homeOver", { what, place, point }) : say(lang, mark === "sun" ? "sunAt" : "homeAt", { what, point });
1289
+ if (this.#markNames.size > 40)
1290
+ this.#markNames.clear();
1291
+ this.#markNames.set(id, text);
1292
+ }
1293
+ return text;
1294
+ }
1295
+ /** Of a satellite and a mark both within reach of a point, the one nearer it: a mark pointed at straight is not lost to a satellite that happens to be close. Returns the mark to use, or null when the satellite is to be. */
1296
+ #markOver(hit, x, y, reach) {
1297
+ const mark = this.#markHit(x, y, reach);
1298
+ if (!mark || !hit)
1299
+ return mark;
1300
+ const spot = this.#markAt[mark];
1301
+ const away = Math.min(...spot.xs.map((at) => Math.hypot(at - x, spot.y - y)));
1302
+ return away < Math.hypot(hit.g.sx[hit.i] - x, hit.g.sy[hit.i] - y) ? mark : null;
1303
+ }
1304
+ /** The mark painted within `reach` pixels of a point, or null. */
1305
+ #markHit(x, y, reach) {
1306
+ for (const mark of ["sun", "home"]) {
1307
+ const spot = this.#markAt[mark];
1308
+ if (spot && Math.abs(spot.y - y) <= reach && spot.xs.some((at) => Math.hypot(at - x, spot.y - y) <= reach))
1309
+ return mark;
1310
+ }
1311
+ return null;
1312
+ }
1313
+ /** A press on a mark, with a finger, a mouse or the keyboard: its name stays beside it (a finger has no pointer to hover), it is read aloud, and the page is told with `chikyu-flat-mark`. */
1314
+ #pressMark(mark, via) {
1315
+ const spot = this.#markAt[mark];
1316
+ if (!spot)
1317
+ return;
1318
+ this.#markShown = mark;
1319
+ this.#placeMarks();
1320
+ const lang = this.language;
1321
+ const text = this.#markText(mark);
1322
+ if (this.#live)
1323
+ this.#live.textContent = text;
1324
+ this.dispatchEvent(new CustomEvent("chikyu-flat-mark", { detail: { mark, name: say(lang, mark === "sun" ? "sunMark" : "homeMark"), text, lon: spot.lon, lat: spot.lat, place: placeOver(spot.lon, spot.lat, lang), via }, bubbles: true, composed: true }));
1325
+ }
1326
+ /** The keyboard's way to the marks: a button over each, with its name, that takes no pointer. Moved when the map is drawn. */
1327
+ #placeMarkButtons() {
1328
+ const lang = this.language;
1329
+ for (const mark of ["sun", "home"]) {
1330
+ const button = this.#markButtons[mark];
1331
+ const spot = this.#markAt[mark];
1332
+ if (!button)
1333
+ continue;
1334
+ button.hidden = !spot;
1335
+ if (!spot) {
1336
+ if (this.#markShown === mark)
1337
+ this.#markShown = null;
1338
+ continue;
1339
+ }
1340
+ button.style.transform = `translate(${spot.xs[0].toFixed(1)}px,${spot.y.toFixed(1)}px)`;
1341
+ button.setAttribute("aria-label", this.#markText(mark));
1342
+ button.lang = lang;
1343
+ }
1344
+ }
1345
+ /** The key under the map: every mark the map draws now, each with the picture of it and its name. Made again only when what is drawn, the words or the fold change. */
1346
+ #syncLegend() {
1347
+ const box = this.#legend;
1348
+ if (!box)
1349
+ return;
1350
+ const lang = this.language;
1351
+ const wants = this.#wants().has("key");
1352
+ box.hidden = !wants;
1353
+ if (!wants)
1354
+ return;
1355
+ const open = this.#legendIsOpen();
1356
+ const shade = this.getAttribute("shade") !== "off";
1357
+ const photo = this.#look === "photo" && this.#photo?.day != null;
1358
+ const shown = this.#shownGroups();
1359
+ const byPlane = this.#byPlane(shown);
1360
+ const chosen = this.#selected !== null;
1361
+ const entries = [];
1362
+ if (shade)
1363
+ entries.push({ glyph: "sun", text: say(lang, "keySun") });
1364
+ if (this.#home())
1365
+ entries.push({ glyph: "home", text: say(lang, "keyHome") });
1366
+ if (shown.length > 0)
1367
+ 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
+ if (this.#faint)
1369
+ entries.push({ glyph: "faint", text: say(lang, "keyFaint") });
1370
+ if (chosen)
1371
+ entries.push({ glyph: "chosen", text: say(lang, "keyRing") });
1372
+ if (this.#footprint)
1373
+ entries.push({ glyph: "footprint", text: say(lang, "keyFootprint") });
1374
+ if (this.#track && chosen) {
1375
+ const colours = this.#trackColours();
1376
+ entries.push({ glyph: "line", text: say(lang, "trackSunlit"), colours: [colours.sun] }, { glyph: "line", text: say(lang, "trackShadow"), colours: [colours.shadow] });
1377
+ }
1378
+ if (shade)
1379
+ entries.push({ glyph: photo ? "night-photo" : "night", text: say(lang, photo ? "keyNightPhoto" : "keyNight") });
1380
+ if (photo)
1381
+ entries.push({ glyph: "nasa", text: this.#creditText() });
1382
+ const key = JSON.stringify([lang, open, entries]);
1383
+ if (key === this.#legendKey)
1384
+ return;
1385
+ this.#legendKey = key;
1386
+ const d = box.ownerDocument;
1387
+ const toggle = d.createElement("button");
1388
+ toggle.type = "button";
1389
+ toggle.dataset["act"] = "key";
1390
+ toggle.setAttribute("aria-expanded", String(open));
1391
+ toggle.setAttribute("aria-controls", "legend-list");
1392
+ toggle.setAttribute("aria-label", say(lang, open ? "keyHide" : "keyShow"));
1393
+ toggle.textContent = `${say(lang, "key")} ${open ? "▾" : "▸"}`;
1394
+ const list = d.createElement("ul");
1395
+ list.id = "legend-list";
1396
+ list.setAttribute("aria-label", say(lang, "keyMarks"));
1397
+ list.hidden = !open;
1398
+ for (const entry of entries) {
1399
+ const item = d.createElement("li");
1400
+ const glyph = d.createElement("span");
1401
+ glyph.className = `g ${entry.glyph}`;
1402
+ glyph.setAttribute("aria-hidden", "true");
1403
+ for (const colour of entry.colours ?? []) {
1404
+ const dot = d.createElement("i");
1405
+ dot.style.setProperty("--c", colour);
1406
+ glyph.append(dot);
1407
+ }
1408
+ item.append(glyph, entry.text);
1409
+ list.append(item);
1410
+ }
1411
+ box.replaceChildren(toggle, list);
1412
+ box.lang = lang;
1413
+ }
1414
+ /** Whether the key's list is open: what the reader chose, else open on a wide map and shut on a narrow one. */
1415
+ #legendIsOpen() {
1416
+ return this.#legendOpen ?? this.#view.width >= 600;
1417
+ }
1418
+ /** The key folded open or shut. A property so a page can set it; the reader's button does the same. */
1419
+ get keyOpen() {
1420
+ return this.#legendIsOpen();
1421
+ }
1422
+ set keyOpen(value) {
1423
+ this.#legendOpen = Boolean(value);
1424
+ this.#syncLegend();
1425
+ this.#request();
1426
+ }
1067
1427
  #nameOf(ref) {
1068
1428
  const set = ref.g.sats.sets[ref.i];
1069
1429
  return SHORT_NAMES[set.NORAD_CAT_ID]?.[this.language] ?? set.OBJECT_NAME;
@@ -1107,14 +1467,44 @@ export class ChikyuFlat extends HTMLElement {
1107
1467
  msg.setAttribute("role", "status");
1108
1468
  const key = Object.assign(d.createElement("p"), { className: "key", hidden: true });
1109
1469
  key.setAttribute("role", "group");
1470
+ const credit = Object.assign(d.createElement("button"), { className: "credit", type: "button", hidden: true });
1471
+ credit.append(d.createElement("span"), d.createElement("span"));
1472
+ credit.children[0].className = "short";
1473
+ credit.children[1].className = "full";
1474
+ credit.setAttribute("aria-expanded", "false");
1475
+ credit.addEventListener("click", () => credit.setAttribute("aria-expanded", String(credit.toggleAttribute("data-open"))));
1476
+ const legend = Object.assign(d.createElement("div"), { className: "legend", hidden: true });
1477
+ legend.setAttribute("role", "group");
1478
+ legend.addEventListener("click", this.#onLegend);
1479
+ const marks = ["sun", "home"].map((mark) => {
1480
+ const button = Object.assign(d.createElement("button"), { className: "mark", type: "button", hidden: true });
1481
+ button.dataset["mark"] = mark;
1482
+ button.addEventListener("focus", () => {
1483
+ this.#markShown = mark;
1484
+ this.#placeMarks();
1485
+ if (this.#live)
1486
+ this.#live.textContent = this.#markText(mark);
1487
+ });
1488
+ button.addEventListener("blur", () => {
1489
+ if (this.#markShown !== mark)
1490
+ return;
1491
+ this.#markShown = null;
1492
+ this.#placeMarks();
1493
+ });
1494
+ button.addEventListener("click", () => this.#pressMark(mark, "key"));
1495
+ this.#markButtons[mark] = button;
1496
+ return button;
1497
+ });
1110
1498
  const live = Object.assign(d.createElement("p"), { className: "sr", id: "live" });
1111
1499
  live.setAttribute("role", "status");
1112
1500
  live.setAttribute("aria-live", "polite");
1113
1501
  const help = Object.assign(d.createElement("p"), { className: "sr", id: "help" });
1114
1502
  dots.setAttribute("aria-describedby", "help live");
1115
- stage.append(map, dots, selRing, hovRing, tip, key, msg);
1503
+ stage.append(map, dots, selRing, hovRing, tip, ...marks, key, credit, msg);
1116
1504
  this.#key = key;
1117
- root.append(bar, stage, live, help);
1505
+ this.#credit = credit;
1506
+ root.append(bar, stage, legend, live, help);
1507
+ this.#legend = legend;
1118
1508
  this.#bar = bar;
1119
1509
  this.#stage = stage;
1120
1510
  this.#mapCanvas = map;
@@ -1143,7 +1533,7 @@ export class ChikyuFlat extends HTMLElement {
1143
1533
  const raw = (this.getAttribute("controls") ?? "").trim().toLowerCase();
1144
1534
  if (raw === "none" || raw === "off")
1145
1535
  return new Set();
1146
- const all = ["centre", "zoom", "footprint", "track", "chips"];
1536
+ const all = ["centre", "zoom", "footprint", "track", "chips", "key"];
1147
1537
  if (raw === "" || raw === "all")
1148
1538
  return new Set(all);
1149
1539
  return new Set(raw.split(/[\s,]+/).map((one) => (one === "center" ? "centre" : one)));
@@ -1168,6 +1558,9 @@ export class ChikyuFlat extends HTMLElement {
1168
1558
  if (Number.isFinite(finite(this.getAttribute("home-lon"), Number.NaN)))
1169
1559
  first.push(button("home", say(lang, "myPlace"), ` aria-label="${escape(say(lang, "centreHome"))}" aria-pressed="false"`));
1170
1560
  }
1561
+ // 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
+ if (wants.has("look"))
1563
+ 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>`);
1171
1564
  if (wants.has("zoom"))
1172
1565
  first.push(`<span class="gap"></span>`, button("zoomout", "−", ` aria-label="${escape(say(lang, "zoomOut"))}"`), button("zoomin", "+", ` aria-label="${escape(say(lang, "zoomIn"))}"`));
1173
1566
  else
@@ -1227,6 +1620,8 @@ export class ChikyuFlat extends HTMLElement {
1227
1620
  set('[data-act="home"]', Number.isFinite(home.lon) && Math.abs(wrapLongitude(this.#view.centerLon - home.lon)) < 0.5);
1228
1621
  set('[data-act="footprint"]', this.#footprint);
1229
1622
  set('[data-act="track"]', this.#track);
1623
+ set('[data-act="look-map"]', this.#look === "map");
1624
+ set('[data-act="look-photo"]', this.#look === "photo");
1230
1625
  const shown = this.#shownGroups();
1231
1626
  bar.querySelectorAll('[data-act="group"]').forEach((chip) => {
1232
1627
  const id = chip.dataset["group"];
@@ -1237,6 +1632,7 @@ export class ChikyuFlat extends HTMLElement {
1237
1632
  bar.querySelector('[data-act="zoomout"]')?.toggleAttribute("disabled", this.#view.zoom <= 1);
1238
1633
  if (this.#dotCanvas)
1239
1634
  this.#dotCanvas.toggleAttribute("data-zoomed", this.#view.zoom > 1);
1635
+ this.#syncLegend();
1240
1636
  }
1241
1637
  #afterFilter() {
1242
1638
  this.#buildBar();
@@ -1244,6 +1640,12 @@ export class ChikyuFlat extends HTMLElement {
1244
1640
  this.#schedule();
1245
1641
  this.dispatchEvent(new CustomEvent("chikyu-flat-filter", { detail: { groups: this.visibleGroups, plane: this.#plane }, bubbles: true, composed: true }));
1246
1642
  }
1643
+ #onLegend = (event) => {
1644
+ if (!event.target?.closest("button[data-act=key]"))
1645
+ return;
1646
+ this.keyOpen = !this.#legendIsOpen();
1647
+ this.#legend?.querySelector("button[data-act=key]")?.focus();
1648
+ };
1247
1649
  #onBar = (event) => {
1248
1650
  const target = event.target?.closest("button[data-act]");
1249
1651
  if (!target || target.hasAttribute("disabled"))
@@ -1266,6 +1668,10 @@ export class ChikyuFlat extends HTMLElement {
1266
1668
  this.#sync();
1267
1669
  this.#request();
1268
1670
  }
1671
+ else if (act === "look-map" || act === "look-photo") {
1672
+ // the attribute is the look: the page that set the controls sees the change as it sees any other
1673
+ this.setAttribute("look", act === "look-photo" ? "photo" : "map");
1674
+ }
1269
1675
  else if (act === "track") {
1270
1676
  this.#track = !this.#track;
1271
1677
  this.#trackKey = "";
@@ -1448,9 +1854,19 @@ export class ChikyuFlat extends HTMLElement {
1448
1854
  this.#dotCanvas.style.cursor = "";
1449
1855
  if (drag && !drag.moved) {
1450
1856
  // a tap: a finger needs more room than a mouse
1451
- const hit = this.#hit(at.x, at.y, event.pointerType === "touch" ? 22 : 9);
1857
+ const near = this.#hit(at.x, at.y, event.pointerType === "touch" ? 22 : 9);
1452
1858
  if (event.pointerType !== "mouse")
1453
1859
  this.#hover = null;
1860
+ const mark = this.#markOver(near, at.x, at.y, event.pointerType === "touch" ? 22 : 11);
1861
+ const hit = mark ? null : near;
1862
+ if (mark) {
1863
+ this.#pressMark(mark, "tap");
1864
+ return;
1865
+ }
1866
+ // a tap anywhere else puts a pressed mark's name away
1867
+ this.#markShown = null;
1868
+ this.#markHover = null;
1869
+ this.#placeMarks();
1454
1870
  this.#choose(hit, "tap");
1455
1871
  }
1456
1872
  }
@@ -1465,16 +1881,24 @@ export class ChikyuFlat extends HTMLElement {
1465
1881
  }
1466
1882
  };
1467
1883
  #onLeave = (event) => {
1468
- if (event.pointerType !== "mouse" || this.#hover === null)
1884
+ if (event.pointerType !== "mouse" || (this.#hover === null && this.#markHover === null))
1469
1885
  return;
1470
1886
  this.#hover = null;
1887
+ this.#markHover = null;
1888
+ if (this.#dotCanvas)
1889
+ this.#dotCanvas.style.cursor = "";
1471
1890
  this.#placeMarks();
1472
1891
  };
1473
1892
  #hoverAt(x, y) {
1474
- const hit = this.#hit(x, y, 8);
1475
- if (sameRef(hit, this.#hover))
1893
+ const near = this.#hit(x, y, 8);
1894
+ const mark = this.#markOver(near, x, y, 11);
1895
+ const hit = mark ? null : near;
1896
+ if (this.#dotCanvas)
1897
+ this.#dotCanvas.style.cursor = mark ? "pointer" : "";
1898
+ if (sameRef(hit, this.#hover) && mark === this.#markHover)
1476
1899
  return;
1477
1900
  this.#hover = hit;
1901
+ this.#markHover = mark;
1478
1902
  this.#placeMarks();
1479
1903
  if (hit)
1480
1904
  this.#pick(hit, "hover");
@@ -1500,6 +1924,10 @@ export class ChikyuFlat extends HTMLElement {
1500
1924
  return;
1501
1925
  }
1502
1926
  if (key === "Escape") {
1927
+ if (this.#markShown) {
1928
+ this.#markShown = null;
1929
+ this.#placeMarks();
1930
+ }
1503
1931
  if (this.#cursor || this.#selected) {
1504
1932
  this.#cursor = null;
1505
1933
  this.#choose(null, "key");