Class: Transformation


Transformation between projected coordinates and base 2d point system. A core class used internally for mapping map's (usually geographical) coordinates to 2d points.

(protected) new Transformation(matrix) [source]

The base 2d point system is a fixed system that is consistent with HTML coordinate system: on X-Axis, left is smaller and right is larger; on Y-Axis, top is smaller and bottom is larger.
As map's coordinates may not be in the same order(e.g. on a mercator projected earth, top is larger and bottom is smaller),
transformation provides mapping functions to map arbitrary coordinates system to the fixed 2d point system.
How to transform is decided by the constructor parameters which is a 4 number array [a, b, c, d]:
a : the order scale of X-axis values 1 means right is larger and -1 means the reverse, left is larger;
b : the order scale of Y-axis values 1 means bottom is larger and -1 means the reverse, top is larger;
c : x of the origin point of the projected coordinate system
d : y of the origin point of the projected coordinate system
e.g.: Transformation parameters for Google map: [1, -1, -20037508.34, 20037508.34]
Parameter Type Description
matrix Array.<Number> transformation array


  • transform(coordinates, scale) [source]

  • Transform a projected coordinate to a 2d point.
    Parameter scale in transform/untransform method is used to scale the result 2d points on map's different zoom levels.
    Parameter Type Description
    coordinates Array.<Number> | Coordinate projected coordinate to transform
    scale Number transform scale
    Point: 2d point.
  • untransform(point, scale) [source]

  • Transform a 2d point to a projected coordinate.
    Parameter Type Description
    point Point 2d point
    scale Number transform scale
    Coordinate: projected coordinate.