本文へ移動

Chizu地図

SVGの地図を描き、地域を表示範囲に収め、番号付きの注記や地理クイズを英語と日本語の名前で作れます。

「地図」は、土地や場所を図で表したものです。 名前について(英語)

目次

リファレンス · 表示範囲・形・クイズの道具

Bounds型

リファレンスの説明と例は英語です。見出しと目次は日本語です。

The box round a shape: left, top, right, bottom.

インポート

import type { Bounds } from "@johnmorrisdotca/chizu";

定義

type Bounds = readonly [
    number,
    number,
    number,
    number
];

メンバー

名前型説明
0number
1number
2number
3number
length4
toString(): string

Returns a string representation of an array.

toLocaleString(): string (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string

Returns a string representation of an array. The elements are converted to string using their toLocaleString methods.

concat(...items: ConcatArray<number>[]): number[] (...items: (number | ConcatArray<number>)[]): number[]

Combines two or more arrays.

join(separator?: string): string

Adds all the elements of an array separated by the specified separator string.

slice(start?: number, end?: number): number[]

Returns a section of an array.

indexOf(searchElement: number, fromIndex?: number): number

Returns the index of the first occurrence of a value in an array.

lastIndexOf(searchElement: number, fromIndex?: number): number

Returns the index of the last occurrence of a specified value in an array.

every<S extends number>(predicate: (value: number, index: number, array: readonly number[]) => value is S, thisArg?: any): this is readonly S[] (predicate: (value: number, index: number, array: readonly number[]) => unknown, thisArg?: any): boolean

Determines whether all the members of an array satisfy the specified test.

some(predicate: (value: number, index: number, array: readonly number[]) => unknown, thisArg?: any): boolean

Determines whether the specified callback function returns true for any element of an array.

forEach(callbackfn: (value: number, index: number, array: readonly number[]) => void, thisArg?: any): void

Performs the specified action for each element in an array.

map<U>(callbackfn: (value: number, index: number, array: readonly number[]) => U, thisArg?: any): U[]

Calls a defined callback function on each element of an array, and returns an array that contains the results.

filter<S extends number>(predicate: (value: number, index: number, array: readonly number[]) => value is S, thisArg?: any): S[] (predicate: (value: number, index: number, array: readonly number[]) => unknown, thisArg?: any): number[]

Returns the elements of an array that meet the condition specified in a callback function.

reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: readonly number[]) => number): number (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: readonly number[]) => number, initialValue: number): number <U>(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: readonly number[]) => U, initialValue: U): U

Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: readonly number[]) => number): number (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: readonly number[]) => number, initialValue: number): number <U>(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: readonly number[]) => U, initialValue: U): U

Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

find<S extends number>(predicate: (value: number, index: number, obj: readonly number[]) => value is S, thisArg?: any): S | undefined (predicate: (value: number, index: number, obj: readonly number[]) => unknown, thisArg?: any): number | undefined

Returns the value of the first element in the array where predicate is true, and undefined otherwise.

findIndex(predicate: (value: number, index: number, obj: readonly number[]) => unknown, thisArg?: any): number

Returns the index of the first element in the array where predicate is true, and -1 otherwise.

entries(): ArrayIterator<[number, number]>

Returns an iterable of key, value pairs for every entry in the array

keys(): ArrayIterator<number>

Returns an iterable of keys in the array

values(): ArrayIterator<number>

Returns an iterable of values in the array

includes(searchElement: number, fromIndex?: number): boolean

Determines whether an array includes a certain element, returning true or false as appropriate.

flatMap<U, This = undefined>(callback: (this: This, value: number, index: number, array: number[]) => U | readonly U[], thisArg?: This | undefined): U[]

Calls a defined callback function on each element of an array. Then, flattens the result into a new array. This is identical to a map followed by flat with depth 1.

flat<A, D extends number = 1>(this: A, depth?: D | undefined): FlatArray<A, D>[]

Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth.

at(index: number): number | undefined

Returns the item located at the specified index.

例

import WORLD from "@johnmorrisdotca/chizu/world";
import type { Bounds } from "@johnmorrisdotca/chizu";

const [left, top, right, bottom]: Bounds = WORLD.regions.find((region) => region.code === "JP")!.bbox;
console.log(right > left && bottom > top);
// true
true

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/chizu 1.5.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。