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

Class TGMLatLng

Unit

Declaration

type TGMLatLng = class(TGMPersistentStr)

Description

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

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

Overview

Fields

Protected FPrecision: Integer;

Methods

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

Properties

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

Description

Fields

Protected FPrecision: Integer;

Precision value to show Lat and Lng. Default 6.

Methods

Public 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.
Public 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.
Public 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.

Public function LatToStr(Precision: Integer = 6): string;

Convert Lat value to a string.

Parameters
Precision
Precision of value. Default 6.
Returns

String with the latitude.

Public function LngToStr(Precision: Integer = 6): string;

Convert Lng value to a string.

Parameters
Precision
Precision of value. Default 6.
Returns

String with the longitude.

Public 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.

Public 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.

Public 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.

Public 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.

Protected 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.

Protected 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.

Public 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.
Public procedure SetLang(Lang: TGMLang);

Set a Lang to the object.

Parameters
Lang
Language to set.
Protected 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

Public property APIUrl;

URL to Google Maps API page.

Published property Lat: Double read GetLat write SetLat;

Latitude in degrees.

Published property Lng: Double read GetLng write SetLng;

Longitude in degrees

Published 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.