Legacy
Mapbox.js is no longer in active development. To learn more about our newer mapping tools see Mapbox GL JS.
You are viewing an older version of Mapbox.js. Check out v3.3.1 for the latest.
Point
Represents a point with x and y coordinates in pixels.
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:
map.panBy([200, 300]);
map.panBy(L.point(200, 300));
Creation
Factory | Description |
---|---|
L.point(
|
Creates a Point object with the given x and y coordinates. If optional round is set to true , rounds the x and y values. |
Properties
Property | Type | Description |
---|---|---|
x |
Number |
The x coordinate. |
y |
Number |
The y coordinate. |
Methods
Method | Returns | Description |
---|---|---|
add(
|
Point |
Returns the result of addition of the current and the given points. |
subtract(
|
Point |
Returns the result of subtraction of the given point from the current. |
multiplyBy(
|
Point |
Returns the result of multiplication of the current point by the given number. |
divideBy(
|
Point |
Returns the result of division of the current point by the given number. If optional round is set to true , returns a rounded result. |
distanceTo(
|
Number |
Returns the distance between the current and the given points. |
clone() |
Point |
Returns a copy of the current point. |
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). |
equals(
|
Boolean |
Returns true if the given point has the same coordinates. |
contains(
|
Boolean |
Returns true if the both coordinates of the given point are less than the corresponding current point coordinates (in absolute values). |
toString() |
String |
Returns a string representation of the point for debugging purposes. |