Skip to the content

Chikyu Earth地球

A line-drawn globe of the world's countries that turns at the Earth's own rate, with an optional realistic Earth from space and markers for any place.

Chikyu is the Japanese word 地球 for the Earth. About the name

Contents

Reference · Markers on the globe

attachMarkersfunction

Put markers on a globe, for either look: dots drawn in one pass on a canvas, a few labels as real buttons, crowded places gathered into clusters. It draws only when the view or the markers change, reads no layout to place a label, and shows no more labels than maxLabels. Hovering, clicking or focusing a marker fires chikyu-marker-hover, chikyu-marker-click and chikyu-marker-focus on the element, with your own data in the detail.

Import it

import { attachMarkers } from "@johnmorrisdotca/chikyu-earth/markers";

Definition

function attachMarkers(element: OverlayElement, options?: MarkerOptions): Markers

Parameters

NameTypeDescription
elementOverlayElement

<chikyu-earth> or <chikyu-earth-realistic>.

options (optional)MarkerOptions

The most labels, the cluster radius and the default colour; each has a default.

Returns

Markers

The markers: add, addAll, update, remove, clear, groups, toggleGroup, stats and detach.

Examples

import "@johnmorrisdotca/chikyu-earth/element";
import { attachMarkers, type MarkerEventDetail } from "@johnmorrisdotca/chikyu-earth/markers";

const earth = document.querySelector("chikyu-earth")!;
const markers = attachMarkers(earth);
markers.add({ id: "tokyo", lon: 139.69, lat: 35.69, label: "Tokyo", group: "Cities" });
earth.addEventListener("chikyu-marker-click", (event) => {
  const { marker } = (event as CustomEvent<MarkerEventDetail>).detail;
  console.log("chose", marker?.label);
});

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/chikyu-earth 0.11.0.