Usage example
var point = L.point(200, 300);
All Leaflet methods and options that accept Point
objects also accept them in a simple Array form (unless noted otherwise), so these lines are equivalent:
所有接受Point对象的Leaflet方法和选项也以简单的Array形式接受它们(除非另有说明),因此这些行是等效的:
map.panBy([200, 300]);
map.panBy(L.point(200, 300));
Note that Point
does not inherit from Leaflet’s Class
object, which means new classes can’t inherit from it, and new methods can’t be added to it with the include
function.
请注意,Point不从Leaflet的Class对象继承,这意味着新的类不能从它继承,并且不能使用include函数向它添加新的方法。
Creation
Methods
Method | Returns | Description |
---|---|---|
clone() | Point | Returns a copy of the current point. 返回当前点的副本。 |
add(<Point> otherPoint) | Point | Returns the result of addition of the current and the given points. 返回当前点和给定点相加的结果。 |
subtract(<Point> otherPoint) | Point | Returns the result of subtraction of the given point from the current. 返回从当前值减去给定点的结果。 |
divideBy(<Number> num) | Point | Returns the result of division of the current point by the given number. 返回当前点除以给定数字的结果。 |
multiplyBy(<Number> num) | Point | Returns the result of multiplication of the current point by the given number. 返回当前点与给定数字相乘的结果。 |
scaleBy(<Point> scale) | Point | Multiply each coordinate of the current point by each coordinate of scale . In linear algebra terms, multiply the point by the scaling matrix defined by scale .将当前点的每个坐标乘以每个比例坐标。在线性代数术语中,将点乘以由比例定义的缩放矩阵。 |
unscaleBy(<Point> scale) | Point | Inverse of scaleBy . Divide each coordinate of the current point by each coordinate of scale .scaleBy的倒数。将当前点的每个坐标除以每个比例坐标。 |
round() | Point | Returns a copy of the current point with rounded coordinates. 返回具有舍入坐标的当前点的副本。 |
floor() | Point | Returns a copy of the current point with floored coordinates (rounded down). 返回具有底部坐标(向下舍入)的当前点的副本。 |
ceil() | Point | Returns a copy of the current point with ceiled coordinates (rounded up). 返回当前点的副本,该副本具有天花板坐标(四舍五入)。 |
trunc() | Point | Returns a copy of the current point with truncated coordinates (rounded towards zero). 返回具有截断坐标(四舍五入到零)的当前点的副本。 |
distanceTo(<Point> otherPoint) | Number | Returns the cartesian distance between the current and the given points. 返回当前点和给定点之间的笛卡尔距离。 |
equals(<Point> otherPoint) | Boolean | Returns true if the given point has the same coordinates.如果给定点具有相同的坐标,则返回true。 |
contains(<Point> otherPoint) | Boolean | Returns true if both coordinates of the given point are less than the corresponding current point coordinates (in absolute values).如果给定点的两个坐标都小于相应的当前点坐标(以绝对值表示),则返回true。 |
toString() | String | Returns a string representation of the point for debugging purposes. 返回用于调试的点的字符串表示形式。 |
Properties
Property | Type | Description |
---|---|---|
x | Number | The x coordinate of the point点的x坐标 |
y | Number | The y coordinate of the point点的y坐标 |