ChizuGeoJson型
リファレンスの説明と例は英語です。見出しと目次は日本語です。
GeoJSON as the engine reads it: a Feature, a FeatureCollection, or a bare geometry, in the loose shape
JSON.parse and an imported .json file give (type is any string, and is checked as the data is read).
Points, MultiPoints, LineStrings, MultiLineStrings, Polygons, MultiPolygons and GeometryCollections are drawn;
coordinates are [longitude, latitude] in degrees, a third number (height) is ignored.
インポート
import type { ChizuGeoJson } from "@johnmorrisdotca/chizu";
定義
type ChizuGeoJson = {
type: string;
id?: string | number;
properties?: Readonly<Record<string, unknown>> | null;
geometry?: ChizuGeoJson | null;
geometries?: readonly ChizuGeoJson[];
features?: readonly ChizuGeoJson[];
coordinates?: unknown;
};
メンバー
| 名前 | 型 | 説明 |
|---|---|---|
type | string | |
id (省略可) | string | number | undefined | |
properties (省略可) | Readonly<Record<string, unknown>> | null | undefined | |
geometry (省略可) | ChizuGeoJson | null | undefined | |
geometries (省略可) | readonly ChizuGeoJson[] | undefined | |
features (省略可) | readonly ChizuGeoJson[] | undefined | |
coordinates (省略可) | unknown |
例
import { localMap, type ChizuGeoJson } from "@johnmorrisdotca/chizu";
const pitch: ChizuGeoJson = {
type: "Feature",
id: "pitch",
properties: { name: "Pitch", kind: "pitch" },
geometry: { type: "Polygon", coordinates: [[[139.7, 35.7], [139.7012, 35.7], [139.7012, 35.7008], [139.7, 35.7008], [139.7, 35.7]]] },
};
console.log(localMap({ centre: [139.7006, 35.7004], widthMetres: 200, data: pitch }).shapes.map((shape) => shape.kind));
// [ 'area' ][ 'area' ]出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。