@allmaps/types

中文文档
1.0.0-beta.24发布于 2026/09/22MITES Module零依赖近 30 天下载 8930

Allmaps TypeScript types

原始使用文档
文档目录59 节
  1. Geometry types
  2. API
  3. Bbox
  4. Color
  5. ColorCount
  6. ColorWithTransparancy
  7. FetchFn
  8. Fit
  9. Gcp
  10. GeojsonFeature
  11. GeojsonFeatureCollection
  12. GeojsonGeometry
  13. GeojsonGeometryType
  14. GeojsonLineString
  15. GeojsonMultiGeometry
  16. GeojsonMultiLineString
  17. GeojsonMultiPoint
  18. GeojsonMultiPolygon
  19. GeojsonPoint
  20. GeojsonPolygon
  21. Geometry
  22. Histogram
  23. HomogeneousTransform
  24. ImageRequest
  25. Line
  26. LineString
  27. Matrix4
  28. MultiGeometryOptions
  29. MultiLineString
  30. MultiPoint
  31. MultiPolygon
  32. Point
  33. Polygon
  34. Rectangle
  35. Region
  36. Ring
  37. Size
  38. SizeObject
  39. SvgAttributes
  40. SvgCircle
  41. SvgGeometry
  42. SvgLine
  43. SvgPolyLine
  44. SvgPolygon
  45. SvgRect
  46. Tile
  47. TileByColumn
  48. TileZoomLevel
  49. Triangle
  50. TypedGeometry
  51. TypedLine
  52. TypedLineString
  53. TypedMultiLineString
  54. TypedMultiPoint
  55. TypedMultiPolygon
  56. TypedPolygon
  57. TypedRectangle
  58. TypedRing
  59. TypedTriangle

@allmaps/types

Allmaps TypeScript types

Geometry types

The following Geometries are used by default Allmaps packages.

type Point = [number, number]

type LineString = Point[]

type Polygon = Point[][]
// A Polygon is an array of rings of at least three points
// Rings are not closed: the first point is not repeated at the end.
// There is no requirement on winding order.

type MultiPoint = Point[]
// Notice that this is equivalent to the LineString type, hence the `isMultiGeometry` option

type MultiLineString = Point[][]
// Notice that this is equivalent to the Polygon type, hence the `isMultiGeometry` option

type MultiPolygon = Point[][][]

type Geometry =
  | Point
  | LineString
  | Polygon
  | MultiPoint
  | MultiLineString
  | MultiPolygon

To interact with external data, the following types are used as well:

GeoJSON Geometries follow the GeoJSON specification.

SVG Geometries are expressed using the following types (but note that some functions allow svg's to be passed as a string):

export type SvgCircle = {
  type: 'circle'
  attributes?: SvgAttributes
  coordinates: Point
}

export type SvgLine = {
  type: 'line'
  attributes?: SvgAttributes
  coordinates: [Point, Point]
}

export type SvgPolyLine = {
  type: 'polyline'
  attributes?: SvgAttributes
  coordinates: Point[]
}

export type SvgPolygon = {
  type: 'polygon'
  attributes?: SvgAttributes
  coordinates: Point[]
}

export type SvgRect = {
  type: 'rect'
  attributes?: SvgAttributes
  coordinates: Point[]
}

export type SvgGeometry =
  | SvgCircle
  | SvgLine
  | SvgPolyLine
  | SvgPolygon
  | SvgRect

API

Bbox

Bbox ([number, number, number, number]). Defined as [xMin, yMin, xMax, yMax]

Color

Type
[number, number, number]

ColorCount

Fields
  • color ([number, number, number])
  • count (number)

ColorWithTransparancy

Type
[number, number, number, number]

FetchFn

Type
(
  input: Request | string | URL,
  init?: RequestInit
) => Promise<Response>

Fit

Ways two rectangles (or shapes in general) can overlap: ('contain' | 'cover' | 'equal').

  • 'contain': The first contains the second
  • 'cover': The first is covered by the second
  • 'equal': The first and second have equal size

Gcp

Fields
  • geo ([number, number])
  • resource ([number, number])

GeojsonFeature

Fields
  • geometry ( | GeojsonLineString | GeojsonMultiLineString | GeojsonMultiPoint | GeojsonMultiPolygon | GeojsonPoint | GeojsonPolygon)
  • properties (unknown)
  • type ('Feature')

GeojsonFeatureCollection

Fields
  • features (Array<GeojsonFeature>)
  • type ('FeatureCollection')

GeojsonGeometry

Type
  | GeojsonLineString
  | GeojsonMultiLineString
  | GeojsonMultiPoint
  | GeojsonMultiPolygon
  | GeojsonPoint
  | GeojsonPolygon

GeojsonGeometryType

Type
  | 'LineString'
  | 'MultiLineString'
  | 'MultiPoint'
  | 'MultiPolygon'
  | 'Point'
  | 'Polygon'

GeojsonLineString

Fields
  • coordinates (Array<Array<number>>)
  • type ('LineString')

GeojsonMultiGeometry

Type
GeojsonMultiLineString | GeojsonMultiPoint | GeojsonMultiPolygon

GeojsonMultiLineString

Fields
  • coordinates (Array<Array<Array<number>>>)
  • type ('MultiLineString')

GeojsonMultiPoint

Fields
  • coordinates (Array<Array<number>>)
  • type ('MultiPoint')

GeojsonMultiPolygon

Fields
  • coordinates (Array<Array<Array<Array<number>>>>)
  • type ('MultiPolygon')

GeojsonPoint

Fields
  • coordinates (Array<number>)
  • type ('Point')

GeojsonPolygon

Fields
  • coordinates (Array<Array<Array<number>>>)
  • type ('Polygon')

Geometry

Type
  LineString | MultiLineString | MultiPoint | MultiPolygon | Point | Polygon

Histogram

Fields
  • [bin: string] ({count: number; color: Color})

HomogeneousTransform

Weights array of a 2D Homogeneous Transform Matrix

These coefficients are used in the same order in multiple places

  • CSS Transform defined by a 2D matrix. Use toString() before using this as input for a CSS matrix() function.
  • WebGL 2D transform matrices.
  • OpenLayers' transform class.

See: https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix See: https://openlayers.org/en/latest/apidoc/module-ol_transform.html

Note: The weights array of a Polynomial1 Transformation has a different order. See the corresponding conversion functions.

Type
[number, number, number, number, number, number]

ImageRequest

Fields
  • region? ({x: number; y: number; width: number; height: number})
  • size? ({width: number; height: number})

Line

Type
[Point, Point]

LineString

Type
Array<Point>

Matrix4

Type
[
  number,
  number,
  number,
  number,
  number,
  number,
  number,
  number,
  number,
  number,
  number,
  number,
  number,
  number,
  number,
  number
]

MultiGeometryOptions

Fields
  • isMultiGeometry (boolean)

MultiLineString

Type
Array<Array<Point>>

MultiPoint

Type
Array<Point>

MultiPolygon

Type
Array<Array<Array<Point>>>

Point

Type
[number, number]

Polygon

Type
Array<Array<Point>>

Rectangle

Rectangle (or possibly quadrilateral) ([Point, Point, Point, Point]). Winding order of points is free.

Region

Fields
  • height (number)
  • width (number)
  • x (number)
  • y (number)

Ring

Ring as [[number, number], ...] (Array<Point>).

Must contain at least 3 points May not contain duplicate points Must be unclosed: last element is not a repetition of the first May not be self-intersecting So far no requirement on self-intersection although that may be useful in future So far no requirement on winding order. This is only applied when exporting to GeoJSON

Size

Two numbers indicating the size of a Bbox as [width, height] or [xSize, ySize] ([number, number]). Alternatively, two numbers indicating the minimum and maximum of, for example, an array of numbers Alternatively, two numbers indicating the dimensions of a matrix: rows, cols (which is a different handedness!)

SizeObject

Fields
  • height (number)
  • width (number)

SvgAttributes

Type
{[x: string]: string | number}

SvgCircle

Fields
  • attributes? ({[x: string]: string | number})
  • coordinates ([number, number])
  • type ('circle')

SvgGeometry

Type
SvgCircle | SvgLine | SvgPolyLine | SvgPolygon | SvgRect

SvgLine

Fields
  • attributes? ({[x: string]: string | number})
  • coordinates ([Point, Point])
  • type ('line')

SvgPolyLine

Fields
  • attributes? ({[x: string]: string | number})
  • coordinates (Array<Point>)
  • type ('polyline')

SvgPolygon

Fields
  • attributes? ({[x: string]: string | number})
  • coordinates (Array<Point>)
  • type ('polygon')

SvgRect

Fields
  • attributes? ({[x: string]: string | number})
  • coordinates (Array<Point>)
  • type ('rect')

Tile

Fields
  • column (number)
  • imageSize ([number, number])
  • row (number)
  • tileZoomLevel ({ scaleFactor: number width: number height: number originalWidth: number originalHeight: number columns: number rows: number })

TileByColumn

Fields
  • [key: number] ([number, number])

TileZoomLevel

Fields
  • columns (number)
  • height (number)
  • originalHeight (number)
  • originalWidth (number)
  • rows (number)
  • scaleFactor (number)
  • width (number)

Triangle

Triangle As [[x0, y0], [x1, y1], [x2, y2]] ([Point, Point, Point]).

Winding order of points is free.

TypedGeometry

Type
P | TypedLineString<P> | TypedMultiLineString<P> | TypedMultiPoint<P> | TypedMultiPolygon<P> | TypedPolygon<...>

TypedLine

Type
[P, P]

TypedLineString

Type
Array<P>

TypedMultiLineString

Type
Array<Array<P>>

TypedMultiPoint

Type
Array<P>

TypedMultiPolygon

Type
Array<Array<Array<P>>>

TypedPolygon

Type
Array<Array<P>>

TypedRectangle

Type
[P, P, P, P]

TypedRing

Type
Array<P>

TypedTriangle

Type
[P, P, P]

版本与发布记录

@allmaps/types 共发布 20 个版本,首次发布于 2023/04/12;过去 12 个月发布了 4 个版本。

版本发布日期距今
1.0.0-beta.24latest2026/09/221 个月前
1.0.0-beta.232026/05/295 个月前
1.0.0-beta.222025/11/2711 个月前
1.0.0-beta.212025/11/1111 个月前
1.0.0-beta.202025/07/101.3 年前
1.0.0-beta.192025/07/071.3 年前

其他发布通道:beta → 1.0.0-beta.18。

关于 @allmaps/types 的常见问题

@allmaps/types 是什么?

Allmaps TypeScript types

如何安装 @allmaps/types?

在项目目录运行 npm install @allmaps/types,或使用 pnpm add / yarn add / bun add。

@allmaps/types 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/allmaps__types 是否存在。

@allmaps/types 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@allmaps/types 可以商用吗?

@allmaps/types 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@allmaps/types 的下载量有多少?

根据 npm 官方下载统计,@allmaps/types 在 2026/10/06 – 2026/11/04 这 30 天内被下载 8,930 次,日均约 298 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@allmaps/types 还在维护吗?

最新版本 1.0.0-beta.24 发布于 2026/09/22(1 个月前);至今共发布 20 个版本,其中过去 12 个月发布了 4 个;首次发布于 2023/04/12。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。