cadetill's blog | Copyright © Xavier Martínez (cadetill)

# Class TGMLatLng

Description
Hierarchy
Fields
Methods
Properties

## Unit

GMLib.LatLng

## Declaration

`type TGMLatLng = class(TGMPersistentStr)`

## Description

A TGMLatLng is a point in geographical coordinates: latitude and longitude.

- Latitude ranges between -90 and 90 degrees, inclusive. Values above or below this range will be clamped to the range [-90, 90]. This means that if the value specified is less than -90, it will be set to -90. And if the value is greater than 90, it will be set to 90.

- Longitude ranges between -180 and 180 degrees, inclusive. Values above or below this range will be wrapped so that they fall within the range. For example, a value of -190 will be converted to 170. A value of 190 will be converted to -170. This reflects the fact that longitudes wrap around the globe.

Although the default map projection associates longitude with the x-coordinate of the map, and latitude with the y-coordinate, the latitude coordinate is always written first, followed by the longitude.
More information at google.maps.LatLng class.

## Hierarchy

- TObject
- TPersistent
- TInterfacedPersistent
- TGMInterfacedOwnedPersistent
- TGMPersistent
- TGMPersistentStr
- TGMLatLng

## Overview

### Fields

| `FPrecision: Integer;`

### Methods

| `constructor Create(Lat: Real = 0; Lng: Real = 0; NoWrap: Boolean = False; Lang: TGMLang = lnEnglish); reintroduce; overload; virtual;`
| `constructor Create(AOwner: TPersistent; Lat: Real = 0; Lng: Real = 0; NoWrap: Boolean = False); reintroduce; overload; virtual;`
| `function IsEqual(Other: TGMLatLng): Boolean; virtual;`
| `function LatToStr(Precision: Integer = 6): string;`
| `function LngToStr(Precision: Integer = 6): string;`
| `function PropToString: string; override;`
| `function ToJson(Precision: Integer = 6): string;`
| `function ToStr(Precision: Integer = 6): string;`
| `function ToUrlValue(Precision: Integer = 6): string;`
| `function ControlPrecision(Value: Double): Double; virtual;`
| `function GetOwnerLang: TGMLang; override;`
| `procedure Assign(Source: TPersistent); override;`
| `procedure SetLang(Lang: TGMLang);`
| `procedure LatLngToStr(var aLat, aLng: string; Precision: Integer = 6);`

### Properties

| `property APIUrl;`
| `property Lat: Double read GetLat write SetLat;`
| `property Lng: Double read GetLng write SetLng;`
| `property NoWrap: Boolean read FNoWrap write SetNoWrap default False;`

## Description

### Fields

| `FPrecision: Integer;`
Precision value to show Lat and Lng. Default 6.

### Methods

| `constructor Create(Lat: Real = 0; Lng: Real = 0; NoWrap: Boolean = False; Lang: TGMLang = lnEnglish); reintroduce; overload; virtual;`
Constructor class. Creates a LatLng object representing a geographic point. Latitude is specified in degrees within the range [-90, 90]. Longitude is specified in degrees within the range [-180, 180]. Set noWrap to true to enable values outside of this range. ###### Parameters Lat Latitude. Default 0. Lng Longitude. Default 0. NoWrap Allows to put values outside the default range of lat/lng. Precision Precision value to show Lat and Lng. Default 6. Lang TGMLang to use in exceptions.

| `constructor Create(AOwner: TPersistent; Lat: Real = 0; Lng: Real = 0; NoWrap: Boolean = False); reintroduce; overload; virtual;`
Constructor class. Creates a LatLng object representing a geographic point. Latitude is specified in degrees within the range [-90, 90]. Longitude is specified in degrees within the range [-180, 180]. Set noWrap to true to enable values outside of this range. ###### Parameters AOwner Owner of the object. Lat Latitude. Default 0. Lng Longitude. Default 0. NoWrap Allows to put values outside the default range of lat/lng.

| `function IsEqual(Other: TGMLatLng): Boolean; virtual;`
Returns `True` if this LatLng is equals the given LatLng. ###### Parameters Other TGMLatLng to compare. ###### Returns `True` if equals, otherwise `False`.

| `function LatToStr(Precision: Integer = 6): string;`
Convert Lat value to a string. ###### Parameters Precision Precision of value. Default 6. ###### Returns String with the latitude.

| `function LngToStr(Precision: Integer = 6): string;`
Convert Lng value to a string. ###### Parameters Precision Precision of value. Default 6. ###### Returns String with the longitude.

| `function PropToString: string; override;`
Converts all class properties values to a string separated by comma used to send values to a JavaScript function. ###### Returns string with all properties.

| `function ToJson(Precision: Integer = 6): string;`
Convert LatLng to Json representation in format `{"Lat": "xxx", "Lng": "yyy"}`. ###### Parameters Precision Precision of values. Default 6. ###### Returns Json with the conversion.

| `function ToStr(Precision: Integer = 6): string;`
Convert LatLng to string representation in format `(Lat, Lng)`. ###### Parameters Precision Precision of values. Default 6. ###### Returns String with the conversion.

| `function ToUrlValue(Precision: Integer = 6): string;`
Returns a string of the form `"lat,lng"` for this LatLng. By default, round the LatLng to 6 decimal. ###### Parameters Precision Precision of values. Default 6. ###### Returns String with the formatted LatLng.

| `function ControlPrecision(Value: Double): Double; virtual;`
Rounds the Value to the number of decimal places defined by FPrecision. If FPrecision is 0 it does nothing. ###### Parameters Value Value to round. ###### Returns Value rounded to the specified precision.

| `function GetOwnerLang: TGMLang; override;`
Returns the TGMLang of the Owner. If Owner is not assigned or not supports IGMOwnerLang interface then should be returned `lnEnglish`. ###### Returns TGMLang of the owner object.

| `procedure Assign(Source: TPersistent); override;`
Call `Assign` to copy the properties or other attributes form an object to another. The standard form of a call to `Assign` method is `Destination.Assign(Source);` which tells the `Destination` object to copy the contents of the `Source` object to itself. ###### Parameters Source Object to copy the content.

| `procedure SetLang(Lang: TGMLang);`
Set a Lang to the object. ###### Parameters Lang Language to set.

| `procedure LatLngToStr(var aLat, aLng: string; Precision: Integer = 6);`
Converts the Lat and Lng property to a string values. It takes into account the locale. ###### Parameters aLat The latitude. aLng The longitude. Precision Precision of values. Default 6.

### Properties

| `property APIUrl;`
URL to Google Maps API page.

| `property Lat: Double read GetLat write SetLat;`
Latitude in degrees.

| `property Lng: Double read GetLng write SetLng;`
Longitude in degrees

| `property NoWrap: Boolean read FNoWrap write SetNoWrap default False;`
Allows to put values outside the default range of Lat/Lng properties.

Generated by PasDoc 0.15.0.