Back to Firebase Js Sdk

GeoPoint class

docs-devsite/firestore_lite.geopoint.md

12.12.13.9 KB
Original Source

Project: /docs/reference/js/_project.yaml Book: /docs/reference/_book.yaml page_type: reference

{% comment %} DO NOT EDIT THIS FILE! This is generated by the JS SDK team, and any local changes will be overwritten. Changes should be made in the source code at https://github.com/firebase/firebase-js-sdk {% endcomment %}

GeoPoint class

An immutable object representing a geographic location in Firestore. The location is represented as latitude/longitude pair.

Latitude values are in the range of [-90, 90]. Longitude values are in the range of [-180, 180].

<b>Signature:</b>

typescript
export declare class GeoPoint 

Constructors

ConstructorModifiersDescription
(constructor)(latitude, longitude)Creates a new immutable <code>GeoPoint</code> object with the provided latitude and longitude values.

Properties

PropertyModifiersTypeDescription
latitudenumberThe latitude of this <code>GeoPoint</code> instance.
longitudenumberThe longitude of this <code>GeoPoint</code> instance.

Methods

MethodModifiersDescription
fromJSON(json)<code>static</code>Builds a <code>GeoPoint</code> instance from a JSON object created by GeoPoint.toJSON()<!-- -->.
isEqual(other)Returns true if this <code>GeoPoint</code> is equal to the provided one.
toJSON()Returns a JSON-serializable representation of this <code>GeoPoint</code> instance.

GeoPoint.(constructor)

Creates a new immutable GeoPoint object with the provided latitude and longitude values.

<b>Signature:</b>

typescript
constructor(latitude: number, longitude: number);

Parameters

ParameterTypeDescription
latitudenumberThe latitude as number between -90 and 90.
longitudenumberThe longitude as number between -180 and 180.

GeoPoint.latitude

The latitude of this GeoPoint instance.

<b>Signature:</b>

typescript
get latitude(): number;

GeoPoint.longitude

The longitude of this GeoPoint instance.

<b>Signature:</b>

typescript
get longitude(): number;

GeoPoint.fromJSON()

Builds a GeoPoint instance from a JSON object created by GeoPoint.toJSON()<!-- -->.

<b>Signature:</b>

typescript
static fromJSON(json: object): GeoPoint;

Parameters

ParameterTypeDescription
jsonobjecta JSON object represention of a <code>GeoPoint</code> instance

<b>Returns:</b>

GeoPoint

an instance of GeoPoint if the JSON object could be parsed. Throws a FirestoreError if an error occurs.

GeoPoint.isEqual()

Returns true if this GeoPoint is equal to the provided one.

<b>Signature:</b>

typescript
isEqual(other: GeoPoint): boolean;

Parameters

ParameterTypeDescription
otherGeoPointThe <code>GeoPoint</code> to compare against.

<b>Returns:</b>

boolean

true if this GeoPoint is equal to the provided one.

GeoPoint.toJSON()

Returns a JSON-serializable representation of this GeoPoint instance.

<b>Signature:</b>

typescript
toJSON(): {
        latitude: number;
        longitude: number;
        type: string;
    };

<b>Returns:</b>

{ latitude: number; longitude: number; type: string; }

a JSON representation of this object.