リファレンス
表示範囲・形・クイズの道具
import { … } from "@johnmorrisdotca/chizu";
最小化と gzip 圧縮をしたサイズは 18.4 kB(読み込むものをすべて含み、esbuild で計測)
リファレンスの説明と例は英語です。見出しと目次は日本語です。
Chizu 地図: the engine round a map. Framing and zoom, insets, a world that wraps round, the outlines as points,
quiz distractors, the callout placer, pasted place names, and the city scale (localMap: a place's own GeoJSON and
pictures in a local projection), over plain ChizuMap data. Pure functions: each returns
new values and never changes what it was given. No data, no drawing, no page: the maps are
@johnmorrisdotca/chizu/world, /countries/<code> and /divisions/<code>; the drawing is /draw, the
pan-and-zoom map in a page is /mount, and the names of every country are /names.
エクスポート
| 名前 | 種類 | 概要 |
|---|---|---|
applyInsetTransform | 関数 | The same move, applied to a point: a centroid, so a handle follows its region. |
Bounds | 型 | The box round a shape: left, top, right, bottom. |
boxCentre | 関数 | Where a box is looking, which is what a zoom step keeps hold of. |
boxIsWholeMap | 関数 | True when the box shows the whole map rather than a zoomed-in window. |
boxToViewBox | 関数 | A window as an SVG viewBox attribute. |
CALLOUT_INSET | 定数 | How far in from the frame's edge the outermost circle's centre sits, in radii. |
CALLOUT_RADIUS_RATIO | 定数 | The share of the window's width a circle's radius is, unless asked otherwise. |
CALLOUT_ROOMY | 定数 | The sea a circle would like around it, in radii, and what having less costs it - so that open water wins over a bay with barely the room, without a bay being refused when it is the only water a region has. |
calloutFaults | 関数 | The two faults a printed sheet is held to, counted over its placed leaders: pairs that cross, and pairs closer than a radius - or than they start, where two regions start closer than that - counting a line through another number's circle as close too. |
calloutGrid | 関数 | The same places, with the grid they were found on. |
CalloutKeepOut | 型 | The lengths of frame kept clear at the bottom-right corner, in the map's units: up the right edge before the corner and along the bottom edge after it, which is where the credit line is drawn. |
CalloutLand | 型 | One drawn region, as the outlines it is actually drawn with. |
CalloutObstacle | 型 | A box, which is what a leader is kept off and what the credit's corner is. |
CalloutPlace | 型 | One place a circle could sit, and where it sits on the search grid. |
CalloutRequest | 型 | The region codes, framing window, radius, numbering and layout options for a callout sheet. |
calloutSpaces | 関数 | Every place in the frame where a circle fits clear of the land and of the credit's corner, on a grid fine enough to find the water beside a coast. |
CalloutSpot | 型 | One numbered circle placed in open water, and the leader line that joins it to its region. |
CHIZU_FEATURE_GROUPS | 定数 | The six groups, in the order they are drawn: seas under the land, then landforms, lakes, rivers, peaks and capitals on it. |
CHIZU_FEATURE_KINDS | 定数 | The kinds in each group. |
CHIZU_STRINGS | 定数 | Native English and Japanese map controls, descriptions and physical-feature labels. |
ChizuCountry | 型 | One country in the table of every country: its names, and which of the maps has it. |
ChizuFeature | 型 | One named physical feature on a map's canvas: a sea, a lake, a river, a landform or a peak. |
ChizuFeatureChoice | 型 | What to show of a layer: water (seas, lakes and rivers), all, a group (marine, landforms, lakes, rivers, peaks, capitals) or a single kind (strait, reservoir, capital). |
ChizuFeatureGroup | 型 | The six groups the features come in, in the order they are drawn: from Natural Earth's physical files, marine (oceans, seas, bays, straits), under the land, landforms (deserts, ranges, plains), drawn only when chosen, lakes, rivers and peaks; and from kuni 国, capitals (a country's capital, its regions' seats). |
ChizuFeatureKind | 型 | What a named physical feature is: a kind of sea (ocean, sea, gulf, bay, strait, channel, sound, fjord, inlet, lagoon, reef), of lake (lake, reservoir), a river, a landform (desert, range, plateau, plain, peninsula, cape, basin, delta, valley, wetland, tundra, isthmus, depression, lowland, gorge, foothills), a peak, or a country's capital or a region's seat. |
ChizuFeatureLayer | 型 | The named features of one map, drawn on that map's canvas: what loadFeatures(mapId) gives, and what drawChizu and mountChizu take as featureLayer. |
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). |
ChizuGroup | 型 | A named group of places: a continent, a UN M49 subregion, or any set of codes a page names (the countries of the EU, Japan's Kanto region). |
ChizuInset | 型 | A region the map draws in a box of its own, instead of where its projection put it (Alaska, Hawaii, Okinawa). |
ChizuLanguage | 型 | THE WORDS chizu says itself, in English and Japanese: what a screen reader hears of a drawing, and the labels on a mounted map's buttons. |
chizuLanguageOf | 関数 | A language this package has words for, from a tag such as ja-JP or en: Japanese for any ja, English otherwise. |
ChizuLocalCanvas | 型 | What a local map is made of: where, how big in metres, and how many metres a unit of its canvas is. |
ChizuLocalMap | 型 | A map of a small place: a ChizuMap (so every function of the engine takes it) whose canvas is a city or a venue in a local projection, whose regions are the polygons of the data, and which also holds the lines, points, pictures and credits that drawLocal draws. |
ChizuLocalMarker | 型 | A picture placed on a local map: where it is on the canvas, how many canvas units a unit of the picture is, and the turn that puts its top towards its bearing (the bearing less the map's grid convergence, localConvergence). |
ChizuLocalMarkerInput | 型 | A picture to put on a local map, given as the caller has it. |
ChizuLocalOptions | 型 | What a local map is made of. |
ChizuLocalShape | 型 | One shape of a local map, in the canvas's units: an area (a closed outline, filled), a line (an open one) or a point. |
ChizuMap | 型 | A map: a canvas and its regions. |
ChizuPlace | 型 | The part of a region the engine reads, so a map of your own regions needs no more than these. |
ChizuProjection | 型 | How a map's canvas was made from the earth, enough to put a longitude and latitude on it (projectPoint): Miller's cylindrical projection round a centre longitude (the world), a Lambert azimuthal equal-area projection round a centre (one country on its own), or, for a city or a single venue (localMap), a transverse Mercator on the WGS 84 ellipsoid round a centre (radius is its rectifying radius, in metres), a unit of the canvas being metresPerUnit metres. |
ChizuRegion | 型 | One place on a map: a country on the world, a province or state on a country. |
chizuSay | 関数 | A line of the board's words with its {name} values filled in. |
circleMeetsRing | 関数 | Whether a circle of this radius at this point touches the land inside a ring. |
distanceToRing | 関数 | How far a point is from a ring's outline, ignoring which side of it the point is on. |
DISTRACTOR_SCORES | 定数 | What makes one place on a map a convincing wrong answer for another. |
DistractorOptions | 型 | The wrong-answer count, optional seeded random source and candidate restriction. |
distractorScore | 関数 | How tempting candidate is as a wrong answer for target, from 0 up to 200: 100 for a land neighbour, 60 for the same group, and up to 40 for being close, measured against diagonal, the corner-to-corner length of the map (each map is drawn on a canvas of its own, so a distance only means something relative to it). |
featureChosen | 関数 | Whether a feature is among the choices. |
featureKindName | 関数 | What a kind of feature is called, in a language: Sea and 海, Mountain range and 山脈. |
featureKindOf | 関数 | What a feature is called as a kind, on the map it is drawn on: featureKindName, except that a kind may have a word of its own in one country, written kind.<kind>.<COUNTRY> in CHIZU_STRINGS and read from the country in a seat's code (seat-JP-47). |
featureMap | 関数 | A layer as a map of its own: the same canvas, the features as its regions. |
featuresShown | 関数 | The features of a layer that are among the choices, in the layer's order (seas first, peaks last). |
findFeatures | 関数 | The features a few typed letters may mean, best first: a name (English or Japanese) or reading that is the words typed, then one that begins with them, then one with a word that does, then one that holds them anywhere; within each, the higher ranked first. |
findQuestion | 関数 | Makes the question: the target, count of the most tempting wrong answers for it (pickDistractors), and all of them put in a random order. |
FindQuestion | 型 | A "which one is this?" question: the place asked about, the choices (it among its look-alikes) and where it is in them. |
focusBox | 関数 | The window that frames these regions, or the whole map when none are given. |
focusRegionFit | 関数 | What choosing one place computes: zoom in to fit it, whatever zoom the reader was already at. |
groundDistance | 関数 | How far, in metres, two places are from each other, along the ground: the local projection centred half way between them, so within a hair of the ellipsoid up to 400 km. |
groupBox | 関数 | The window that shows a group whole, shaped to the frame it is drawn in (aspect, how much wider than tall), with a little room round it. |
groupMap | 関数 | The map cut down to a group: the same canvas, only the regions whose codes are given (in the map's order), only their boxes, and neighbours only among themselves. |
groupTones | 関数 | Tones that fade every region outside a group (faint unless another tone is named) and leave the group's own as they are, or give them inside's tones: for a map of a continent drawn on the world, with its neighbours as a pale coast round it. |
HANDLE_CLEARANCE | 定数 | How far apart two handle centres must be, in radii. |
HANDLE_LAYOUTS | 定数 | How a map places its numbered handles: on each region, or in the space around it. |
HANDLE_RADIUS_RATIO | 定数 | A handle's radius as a share of the framed width, so it holds up at any zoom. |
HANDLE_SLOTS | 定数 | Positions a handle will try, in order, measured in radii from the centroid. |
HandleBounds | 型 | A box the handles should stay inside, so none is cropped at the frame edge. |
HandleLayout | 型 | The native ordering, candidate positions and constraints used to place numbered callouts. |
handleRadius | 関数 | A handle's radius in the map's own units, for a window this wide and a share of the usual size. |
HandleSpot | 型 | A numbered region’s label position, native land anchor and leader geometry. |
insetFor | 関数 | The inset a region is drawn in, or null when it is drawn where it is. |
insetHoldsWhole | 関数 | Whether a box holds its region whole, rather than only some of its pieces (outlyingBelow, within). |
insetsFor | 関数 | Every box a region is drawn in, in the map's order: none for most, one for Alaska, three for Okinawa (its main islands, the Sakishima Islands and the Daito Islands, each in a box of its own) and three for Tokyo's far islands. |
insetTransform | 関数 | What to do to a region's own geometry to seat it in its box: shrink it to fit if it is too big, centre it in the frame, and leave it at its own size unless the box says it may be magnified. |
InsetTransform | 型 | What to do to a region's own geometry to seat it in its box: a scale, and a move. |
insetTransformAttribute | 関数 | The SVG transform attribute the move is written as. |
isMapZoom | 関数 | Whether a number is one of the zoom steps. |
landAnchor | 関数 | A point on the region's own land, for a leader to end at. |
layoutCallouts | 関数 | Numbered circles in the open space around and between the regions of a map, each with a leader line to its region. |
localCanvasFromBox | 関数 | The local canvas that shows the ground a window on a world or country map shows, so a page can hand over from the map to the city at the moment it has zoomed past what the map knows, with nothing jumping: at its own 1× the local map covers the same ground as the window did. |
localConvergence | 関数 | The angle, in degrees, between true north and the canvas's up at a place: how much a thing that points at a true bearing is turned on a local map. |
localMap | 関数 | A local map: the ground of a city or a venue, from caller-given GeoJSON and pictures, in a projection made for a small piece of the earth. |
mainlandBounds | 関数 | The box around a region as anyone would picture it: its largest outline, and whatever else is close enough to belong in the same glance. |
MAP_ZOOM_LEVELS | 定数 | How far in the map is drawn, as steps rather than a free zoom. |
MapBox | 型 | A window on a map, in the map's own units: what an SVG viewBox says. |
mapBoxFromLocal | 関数 | The window on a world or country map that a local map covers, the way back from the city: the smallest window that holds the ground of the local window (all of the canvas unless box is given). |
mapBoxMetres | 関数 | How many metres of ground a window on a world or country map shows, across and down: the number to compare with a city's size when deciding that a map has been zoomed past what Natural Earth can say and a local map should take over. |
mapDiagonal | 関数 | The corner-to-corner length of a map's canvas, which proximity is measured against. |
MapOutline | 型 | A map's outlines, drawn where they are drawn: a region in a box carried into it, outlying islands in a box carried into theirs, everything else where the projection put it. |
mapOutlines | 関数 | The outlines of every region of a map, in the map's order, with a point on each one's land. |
MapPiece | 型 | How one region is drawn: usually in one piece, where it is. |
mapRegionPieces | 関数 | The region’s separate drawn pieces, including the geometry moved into its inset boxes. |
MapRing | 型 | One closed outline: a region's mainland, or one of its islands. |
mapWrapsAround | 関数 | Whether this map's east and west edges are the same edge. |
MapZoom | 型 | One of the native whole-number zoom steps from 1 to 10. |
MatchOptions | 型 | A set of regions made from a list of place names somebody pasted. |
nameOf | 関数 | What a region is called in a language: the English name, or in Japanese the everyday short name where there is one (アメリカ), else the full Japanese name, else the English. |
nearestWrappedBox | 関数 | The copy of a window nearest another one. |
orderByPosition | 関数 | The choices in the order they run across the map, west to east. |
parseMapRings | 関数 | The rings of one region's path, in the order it draws them, each with its own box. |
PastedPlaces | 型 | Matched native places in paste order and the original text items that were not found. |
pickDistractors | 関数 | The wrong answers to "which one is this?": the codes of count places, drawn from the most tempting ones for the target, never the target itself. |
placeCallouts | 関数 | Places every circle in the open space around the map. |
placeHandles | 関数 | Places every handle clear of the ones before it. |
placesFromText | 関数 | The regions a paste names. |
pointInRing | 関数 | Whether a point is inside a ring, by the crossing rule. |
POLISH_CIRCLE_CLEAR_RADII | 定数 | How far a leader keeps from the middle of another number's circle, in radii: past the ring, with air. |
POLISH_CLOSE_RADII | 定数 | How close two leaders may come, in radii. |
projectPoint | 関数 | Where a longitude and latitude (in degrees) fall on the map's canvas, as [x, y]; null for a map whose canvas cannot be reversed from here. |
Random | 型 | A number in [0, 1), like Math.random, from a stream a seed fixes. |
regionBox | 関数 | A window tight on one region, for drawing it on its own. |
regionCentre | 関数 | The middle of a region, for zooming to whatever somebody just chose: where it is drawn, not where it is. |
regionGroups | 関数 | The groups a map's regions fall in, by their group, in the order the map first names them: the continents on the world, the eight regions on Japan's prefectures, the four Census regions on the United States'. |
Scorable | 型 | The parts of a place this scoring reads, so a map of your own places needs no more than these. |
seaAround | 関数 | How much water is around a point before this ring's land, never looking further than reach - a place far from every coast only has to be known to be far, and walking six thousand points to find out how far is the bill this runs up on every draw. |
seededRandom | 関数 | A stream of numbers in [0, 1) fixed by a seed. |
segmentCrossesBox | 関数 | Whether a straight leader from a to b passes through this box. |
segmentMeetsRing | 関数 | Whether a straight line from one point to another passes over the land inside a ring. |
segmentsCross | 関数 | Whether two leaders cross. |
segmentsGap | 関数 | How close two leaders come, where they do not cross: the nearest any point of one gets to the other. |
shapeGlyphBox | 関数 | A square window on one region's own outline, for drawing it as an icon: every shape gets the same box and fills it, so a small region is as legible in a list as a large one. |
shiftedOutlines | 関数 | Copies of the outlines translated horizontally by the supplied map-unit offset. |
shuffled | 関数 | A copy of the list in a random order (Fisher–Yates, from the end); the list given is left alone. |
splitPastedPlaces | 関数 | A paste split into its lines, on the separators a pasted list actually uses. |
stepMapZoom | 関数 | One step in or out, clamped: the ends stay put rather than wrapping. |
unprojectPoint | 関数 | The longitude and latitude (in degrees) of a point on the map's canvas, as [lon, lat]; null where projectPoint is. |
VERSION | 定数 | The package's version, which a test holds equal to package.json's. |
wholeMapBox | 関数 | The whole canvas as a window. |
wrapAcross | 関数 | A coordinate brought back onto the canvas, for a pan that has gone round. |
wrapIntoBox | 関数 | The copy of a point that this window shows, or null when it shows none. |
wrapOffsets | 関数 | The copies of the canvas this window sees, as x offsets in map units: [0] while the window is wholly on the canvas, which is most of the time. |
zoomBox | 関数 | The window a zoom step and a centre make. |
zoomToFit | 関数 | The zoom step and centre that show all of these regions at once: for opening a region from its heading, which wants it filling the view and not the whole map with a few regions lit somewhere in it. |
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。