Leaflet Map Point—表示以像素为单位的x和y坐标的点

Leaflet Map Point—表示以像素为单位的x和y坐标的点

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

FactoryDescription
L.point(<Number> x, <Number> 
y, <Boolean> round?)
Creates a Point object with the given x and y coordinates. If optional round is set to true, rounds the x and y values.
使用给定的x和y坐标创建Point对象。如果可选舍入设置为true,则舍入x和y值。
L.point(<Number[]> coords)Expects an array of the form [x, y] instead.
应为[x,y]形式的数组。
L.point(<Object> coords)Expects a plain object of the form {x: Number, y: Number} instead.
应为{x:Number,y:Number}形式的纯对象。

Methods

MethodReturnsDescription
clone()PointReturns a copy of the current point.
返回当前点的副本。
add(<PointotherPoint)PointReturns the result of addition of the current and the given points.
返回当前点和给定点相加的结果。
subtract(<PointotherPoint)PointReturns the result of subtraction of the given point from the current.
返回从当前值减去给定点的结果。
divideBy(<Number> num)PointReturns the result of division of the current point by the given number.
返回当前点除以给定数字的结果。
multiplyBy(<Number> num)PointReturns the result of multiplication of the current point by the given number.
返回当前点与给定数字相乘的结果。
scaleBy(<Pointscale)PointMultiply 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(<Pointscale)PointInverse of scaleBy. Divide each coordinate of the current point by each coordinate of scale.
scaleBy的倒数。将当前点的每个坐标除以每个比例坐标。
round()PointReturns a copy of the current point with rounded coordinates.
返回具有舍入坐标的当前点的副本。
floor()PointReturns a copy of the current point with floored coordinates (rounded down).
返回具有底部坐标(向下舍入)的当前点的副本。
ceil()PointReturns a copy of the current point with ceiled coordinates (rounded up).
返回当前点的副本,该副本具有天花板坐标(四舍五入)。
trunc()PointReturns a copy of the current point with truncated coordinates (rounded towards zero).
返回具有截断坐标(四舍五入到零)的当前点的副本。
distanceTo(<PointotherPoint)NumberReturns the cartesian distance between the current and the given points.
返回当前点和给定点之间的笛卡尔距离。
equals(<PointotherPoint)BooleanReturns true if the given point has the same coordinates.
如果给定点具有相同的坐标,则返回true。
contains(<PointotherPoint)BooleanReturns true if both coordinates of the given point are less than the corresponding current point coordinates (in absolute values).
如果给定点的两个坐标都小于相应的当前点坐标(以绝对值表示),则返回true。
toString()StringReturns a string representation of the point for debugging purposes.
返回用于调试的点的字符串表示形式。

Properties

PropertyTypeDescription
xNumberThe x coordinate of the point
点的x坐标
yNumberThe y coordinate of the point
点的y坐标
0 0 投票数
文章评分
订阅评论
提醒
0 评论
内联反馈
查看所有评论
0
希望看到您的想法,请您发表评论x