---
title: "Point | JavaScript maps SDK"
description: "Documentation for MapTiler SDK"
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# Class Point

A standalone point geometry with useful accessor, comparison, and modification methods.

#### Param: x[](#param-x)

the x-coordinate. This could be longitude or screen pixels, or any other sort of unit.

#### Param: y[](#param-y)

the y-coordinate. This could be latitude or screen pixels, or any other sort of unit.

#### Example[](#example)

```typescript
const point = new Point(-77, 38);
```

#### Hierarchy ([View Summary](https://docs.maptiler.com/sdk-js/api-reference/hierarchy/#Externals.Point))

-   Point
    -   [Anchor](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.Anchor/)

##### Index

### Constructors[](#constructors)

[constructor](#constructor)

### Properties[](#properties)

[x](#x) [y](#y)

### Methods[](#methods)

[add](#add) [angle](#angle) [angleTo](#angleto) [angleWith](#anglewith) [angleWithSep](#anglewithsep) [clone](#clone) [dist](#dist) [distSqr](#distsqr) [div](#div) [divByPoint](#divbypoint) [equals](#equals) [mag](#mag) [matMult](#matmult) [mult](#mult) [multByPoint](#multbypoint) [perp](#perp) [rotate](#rotate) [rotateAround](#rotatearound) [round](#round) [sub](#sub) [unit](#unit)

## Constructors[](#constructors-1)

### constructor[](#constructor)

-   new Point(x: number, y: number): Point[](#constructorpoint)
    
    A standalone point geometry with useful accessor, comparison, and modification methods.
    
    #### Parameters
    
    -   x: number
        
        the x-coordinate. This could be longitude or screen pixels, or any other sort of unit.
        
    -   y: number
        
        the y-coordinate. This could be latitude or screen pixels, or any other sort of unit.
        
    
    #### Returns Point
    
    #### Example[](#example-1)
    
    ```typescript
    const point = new Point(-77, 38);
    ```

## Properties[](#properties-1)

### x[](#x)

x: number

### y[](#y)

y: number

## Methods[](#methods-1)

### add[](#add)

-   add(p: Point): Point[](#add-1)
    
    Add this point's x & y coordinates to another point, yielding a new point.
    
    #### Parameters
    
    -   p: Point
        
        the other point
        
    
    #### Returns Point
    
    output point
    

### angle[](#angle)

-   angle(): number[](#angle-1)
    
    Get the angle from the 0, 0 coordinate to this point, in radians coordinates.
    
    #### Returns number
    
    angle
    

### angleTo[](#angleto)

-   angleTo(b: Point): number[](#angleto-1)
    
    Get the angle from this point to another point, in radians
    
    #### Parameters
    
    -   b: Point
        
        the other point
        
    
    #### Returns number
    
    angle
    

### angleWith[](#anglewith)

-   angleWith(b: Point): number[](#anglewith-1)
    
    Get the angle between this point and another point, in radians
    
    #### Parameters
    
    -   b: Point
        
        the other point
        
    
    #### Returns number
    
    angle
    

### angleWithSep[](#anglewithsep)

-   angleWithSep(x: number, y: number): number[](#anglewithsep-1)
    
    Find the angle of the two vectors, solving the formula for the cross product a x b = |a||b|sin(θ) for θ.
    
    #### Parameters
    
    -   x: number
        
        the x-coordinate
        
    -   y: number
        
        the y-coordinate
        
    
    #### Returns number
    
    the angle in radians
    

### clone[](#clone)

-   clone(): Point[](#clone-1)
    
    Clone this point, returning a new point that can be modified without affecting the old one.
    
    #### Returns Point
    
    the clone
    

### dist[](#dist)

-   dist(p: Point): number[](#dist-1)
    
    Calculate the distance from this point to another point
    
    #### Parameters
    
    -   p: Point
        
        the other point
        
    
    #### Returns number
    
    distance
    

### distSqr[](#distsqr)

-   distSqr(p: Point): number[](#distsqr-1)
    
    Calculate the distance from this point to another point, without the square root step. Useful if you're comparing relative distances.
    
    #### Parameters
    
    -   p: Point
        
        the other point
        
    
    #### Returns number
    
    distance
    

### div[](#div)

-   div(k: number): Point[](#div-1)
    
    Divide this point's x & y coordinates by a factor, yielding a new point.
    
    #### Parameters
    
    -   k: number
        
        factor
        
    
    #### Returns Point
    
    output point
    

### divByPoint[](#divbypoint)

-   divByPoint(p: Point): Point[](#divbypoint-1)
    
    Divide this point's x & y coordinates by point, yielding a new point.
    
    #### Parameters
    
    -   p: Point
        
        the other point
        
    
    #### Returns Point
    
    output point
    

### equals[](#equals)

-   equals(other: Point): boolean[](#equals-1)
    
    Judge whether this point is equal to another point, returning true or false.
    
    #### Parameters
    
    -   other: Point
        
        the other point
        
    
    #### Returns boolean
    
    whether the points are equal
    

### mag[](#mag)

-   mag(): number[](#mag-1)
    
    Return the magnitude of this point: this is the Euclidean distance from the 0, 0 coordinate to this point's x and y coordinates.
    
    #### Returns number
    
    magnitude
    

### matMult[](#matmult)

-   matMult(m: \[number, number, number, number\]): Point[](#matmult-1)
    
    Multiply this point by a 4x1 transformation matrix
    
    #### Parameters
    
    -   m: \[number, number, number, number\]
        
        transformation matrix
        
    
    #### Returns Point
    
    output point
    

### mult[](#mult)

-   mult(k: number): Point[](#mult-1)
    
    Multiply this point's x & y coordinates by a factor, yielding a new point.
    
    #### Parameters
    
    -   k: number
        
        factor
        
    
    #### Returns Point
    
    output point
    

### multByPoint[](#multbypoint)

-   multByPoint(p: Point): Point[](#multbypoint-1)
    
    Multiply this point's x & y coordinates by point, yielding a new point.
    
    #### Parameters
    
    -   p: Point
        
        the other point
        
    
    #### Returns Point
    
    output point
    

### perp[](#perp)

-   perp(): Point[](#perp-1)
    
    Compute a perpendicular point, where the new y coordinate is the old x coordinate and the new x coordinate is the old y coordinate multiplied by -1
    
    #### Returns Point
    
    perpendicular point
    

### rotate[](#rotate)

-   rotate(a: number): Point[](#rotate-1)
    
    Rotate this point around the 0, 0 origin by an angle a, given in radians
    
    #### Parameters
    
    -   a: number
        
        angle to rotate around, in radians
        
    
    #### Returns Point
    
    output point
    

### rotateAround[](#rotatearound)

-   rotateAround(a: number, p: Point): Point[](#rotatearound-1)
    
    Rotate this point around p point by an angle a, given in radians
    
    #### Parameters
    
    -   a: number
        
        angle to rotate around, in radians
        
    -   p: Point
        
        Point to rotate around
        
    
    #### Returns Point
    
    output point
    

### round[](#round)

-   round(): Point[](#round-1)
    
    Return a version of this point with the x & y coordinates rounded to integers.
    
    #### Returns Point
    
    rounded point
    

### sub[](#sub)

-   sub(p: Point): Point[](#sub-1)
    
    Subtract this point's x & y coordinates to from point, yielding a new point.
    
    #### Parameters
    
    -   p: Point
        
        the other point
        
    
    #### Returns Point
    
    output point
    

### unit[](#unit)

-   unit(): Point[](#unit-1)
    
    Calculate this point but as a unit vector from 0, 0, meaning that the distance from the resulting point to the 0, 0 coordinate will be equal to 1 and the angle from the resulting point to the 0, 0 coordinate will be the same as before.
    
    #### Returns Point
    
    unit vector point
