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

Class TGMCustomMap

Unit

Declaration

type TGMCustomMap = class(TGMComponent, IGMExecJS, IGMControlChanges)

Description

Base class for google.maps.Map class.

Implements IGMExecJS and IGMControlChanges interfaces.

More information at google.maps.Map class

Hierarchy

Overview

Fields

Protected FBrowser: TComponent;

Methods

Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Protected function GetHTMLCode: string;
Protected function GetJsonFromHTMLForms: string; virtual; abstract;
Public procedure Assign(Source: TPersistent); override;
Protected procedure DoOpenMap; virtual;
Protected procedure ExecuteJavaScript(FunctName, Params: string); virtual; abstract;
Protected procedure LoadBlankPage; virtual; abstract;
Protected procedure LoadMap; virtual; abstract;
Protected procedure OnTimer(Sender: TObject); virtual;
Protected procedure PropertyChanged(Prop: TPersistent; PropName: string);
Protected procedure SetCenterProperty(LatLng: TGMLatLng); virtual; abstract;
Protected procedure SetEnableTimer(State: Boolean); virtual; abstract;
Protected procedure SetIntervalTimer(Interval: Integer); virtual; abstract;
Protected procedure SetMapTypeIdProperty(MapTypeId: TGMMapTypeId); virtual; abstract;
Protected procedure SetZoomProperty(Zoom: Integer); virtual; abstract;

Properties

Protected property Active: Boolean read FActive write SetActive default False;
Protected property AfterPageLoaded: TGMAfterPageLoaded read FAfterPageLoaded write FAfterPageLoaded;
Protected property APIKey: string read FAPIKey write SetAPIKey;
Protected property APILang: TGMAPILang read FAPILang write SetAPILang default lEnglish;
Protected property APIRegion: TGMAPIRegion read FAPIRegion write SetAPIRegion default rUndefined;
Protected property APIVer: TGMAPIVer read FAPIVer write SetAPIVer default avWeekly;
Protected property ByciclingLayer: TGMByciclingLayer read FByciclingLayer write FByciclingLayer;
Protected property IntervalEvents: Integer read FIntervalEvents write SetIntervalEvents default 50;
Protected property KmlLayer: TGMKmlLayer read FKmlLayer write FKmlLayer;
Protected property OnActiveChange: TNotifyEvent read FOnActiveChange write FOnActiveChange;
Protected property OnBoundsChanged: TGMBoundsChangedEvent read FOnBoundsChanged write FOnBoundsChanged;
Protected property OnCenterChanged: TGMLatLngEvent read FOnCenterChanged write FOnCenterChanged;
Protected property OnClick: TGMLatLngEvent read FOnClick write FOnClick;
Protected property OnContextmenu: TGMLatLngEvent read FOnContextmenu write FOnContextmenu;
Protected property OnDblClick: TGMLatLngEvent read FOnDblClick write FOnDblClick;
Protected property OnDrag: TNotifyEvent read FOnDrag write FOnDrag;
Protected property OnDragEnd: TNotifyEvent read FOnDragEnd write FOnDragEnd;
Protected property OnDragStart: TNotifyEvent read FOnDragStart write FOnDragStart;
Protected property OnIntervalEventsChange: TNotifyEvent read FOnIntervalEventsChange write FOnIntervalEventsChange;
Protected property OnMapTypeIdChanged: TGMMapTypeIdChangedEvent read FOnMapTypeIdChanged write FOnMapTypeIdChanged;
Protected property OnMouseMove: TGMLatLngEvent read FOnMouseMove write FOnMouseMove;
Protected property OnMouseOut: TGMLatLngEvent read FOnMouseOut write FOnMouseOut;
Protected property OnMouseOver: TGMLatLngEvent read FOnMouseOver write FOnMouseOver;
Protected property OnPrecisionChange: TNotifyEvent read FOnPrecisionChange write FOnPrecisionChange;
Protected property OnPropertyChanges: TGMPropertyChangesEvent read FOnPropertyChanges write FOnPropertyChanges;
Protected property OnZoomChanged: TGMZoomChangedEvent read FOnZoomChanged write FOnZoomChanged;
Public property Precision: Integer read FPrecision write SetPrecision default 0;
Protected property TrafficLayer: TGMTrafficLayer read FTrafficLayer write FTrafficLayer;
Protected property TransitLayer: TGMTransitLayer read FTransitLayer write FTransitLayer;

Description

Fields

Protected FBrowser: TComponent;

Browser where display the Google Maps map.

Methods

Public constructor Create(AOwner: TComponent); override;

Class constructor.

Creates a TGMCustomMap object.

Parameters
AOwner
Owner of the object.
Public destructor Destroy; override;

Destructor class.

Protected function GetHTMLCode: string;

Returns the HTML code of map.html on gmmapres.res.

Internal use only.

Returns

String with the HTML code.

Exceptions raised
EGMUnassignedObject
This exception is raised when the Browser property is not assigned.
EGMCanLoadResource
This exception is raised if the resoource of the map can't be load.
Protected function GetJsonFromHTMLForms: string; virtual; abstract;

Reads all fields of all HTML forms and returns a Json with their values.

Returns

Json with the info.

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.
Protected procedure DoOpenMap; virtual;

Executes the necessary scripts to display the map in the browser.

Protected procedure ExecuteJavaScript(FunctName, Params: string); virtual; abstract;

Execute the JavaScript function FunctName with parameters Params.

If executed succefully returns True, otherwise False.

Parameters
FunctName
JavaScript function name to execute.
Params
Function parameters.
Protected procedure LoadBlankPage; virtual; abstract;

LoadBlankPage method load the about:blank page.

Exceptions raised
EGMIncorrectBrowser
This exception is raised when the Browser object isn't of the correct class.
EGMUnassignedObject
This exception is raised when the Browser property is not assigned.
Protected procedure LoadMap; virtual; abstract;

LoadMap method loads and shows the map.html to use Google Maps API.

The timeout for load page is 15 seconds.

Exceptions raised
EGMIncorrectBrowser
This exception is raised when the class of assigned browser isn't correct.
EGMUnassignedObject
This exception is raised when the Browser property is not assigned.
Protected procedure OnTimer(Sender: TObject); virtual;

OnTimer control event of Timer that check events from map. Internal use only.

Parameters
Sender
Object that fire event
Protected procedure PropertyChanged(Prop: TPersistent; PropName: string);

Method to call into the owner object when changes a property into the current object.

Parameters
Prop
Object property that has changed.
PropName
Name of the property that has changed.
Protected procedure SetCenterProperty(LatLng: TGMLatLng); virtual; abstract;

Assigns the new map center value readed from HTML map code.

@params LatLng The new TGMLatLng

Protected procedure SetEnableTimer(State: Boolean); virtual; abstract;

Enables or disables the Timer that controls the map events.

For internal use.

Parameters
State
Value to be set to Timer status
Protected procedure SetIntervalTimer(Interval: Integer); virtual; abstract;

Set the interval of Timer that control de map events.

Internal use only.

Parameters
Interval
Interval in miliseconds
Protected procedure SetMapTypeIdProperty(MapTypeId: TGMMapTypeId); virtual; abstract;

Assigns the new MapTypeId value readed from HTML map code.

@params MapTypeId The new TGMMapTypeId

Protected procedure SetZoomProperty(Zoom: Integer); virtual; abstract;

Assigns the new Zoom value readed from HTML map code.

@params Zoom The new zoom

Properties

Protected property Active: Boolean read FActive write SetActive default False;

Activate or deactivate access to the map.

Protected property AfterPageLoaded: TGMAfterPageLoaded read FAfterPageLoaded write FAfterPageLoaded;

AfterPageLoaded event is fired when page is loaded.

If param First is True, the base HTML code es loaded. When False the map is loaded.

See TGMAfterPageLoaded for more info.

Protected property APIKey: string read FAPIKey write SetAPIKey;

APIKey is the Key to use on Google Maps.

To obtaining Api Key please check: https://developers.google.com/maps/documentation/javascript/get-api-key

Google Maps limits:

Exceptions raised
EGMMapIsActive
This exception is raised when Active property is True.
Protected property APILang: TGMAPILang read FAPILang write SetAPILang default lEnglish;

By default the API will attempt to load the most appropriate language based on the users location or browser settings.

But some APIs allow you to explicitly set a language when you make a request.

More info at Localizing the Map and more specific at Supported Languages

Exceptions raised
EGMMapIsActive
This exception is raised when Active property is True.
Protected property APIRegion: TGMAPIRegion read FAPIRegion write SetAPIRegion default rUndefined;

When you load the Maps JavaScript API from maps.googleapis.com it applies a default bias for application behavior towards the United States.

If you want to alter your application to serve different map tiles or bias the application (such as biasing geocoding results towards the region), you can override this default behavior by adding a region.

More info at Localizing the Map and more specific at Google Maps Platform Coverage Details

Exceptions raised
EGMMapIsActive
This exception is raised when Active property is True.
Protected property APIVer: TGMAPIVer read FAPIVer write SetAPIVer default avWeekly;

Version of the Google Maps API to use.

More info at Versioning

Exceptions raised
EGMMapIsActive
This exception is raised when Active property is True.
Protected property ByciclingLayer: TGMByciclingLayer read FByciclingLayer write FByciclingLayer;

Class for google.maps.BicyclingLayer class.

More information at google.maps.BicyclingLayer class

Protected property IntervalEvents: Integer read FIntervalEvents write SetIntervalEvents default 50;

Interval of time to check the events of map.

Protected property KmlLayer: TGMKmlLayer read FKmlLayer write FKmlLayer;

Class for google.maps.KmlLayer class.

More information at google.maps.KmlLayer class

Protected property OnActiveChange: TNotifyEvent read FOnActiveChange write FOnActiveChange;

OnActiveChange event is fired when Active property value changes.

Protected property OnBoundsChanged: TGMBoundsChangedEvent read FOnBoundsChanged write FOnBoundsChanged;

This event is fired when the viewport bounds have changed.

See TGMBoundsChangedEvent for more info.

Protected property OnCenterChanged: TGMLatLngEvent read FOnCenterChanged write FOnCenterChanged;

This event is fired when the map center property changes.

This event changes the Center property.

See TGMLatLngEvent for more info.

Protected property OnClick: TGMLatLngEvent read FOnClick write FOnClick;

This event is fired when the user clicks on the map.

See TGMLatLngEvent for more info.

Protected property OnContextmenu: TGMLatLngEvent read FOnContextmenu write FOnContextmenu;

This event is fired when the DOM contextmenu event is fired on the map container or when the user rightclicks on the map.

See TGMLatLngEvent for more info.

Protected property OnDblClick: TGMLatLngEvent read FOnDblClick write FOnDblClick;

This event is fired when the user double-clicks on the map.

Note that the click event will also fire, right before this one.

See TGMLatLngEvent for more info.

Protected property OnDrag: TNotifyEvent read FOnDrag write FOnDrag;

This event is repeatedly fired while the user drags the map.

Protected property OnDragEnd: TNotifyEvent read FOnDragEnd write FOnDragEnd;

This event is fired when the user stops dragging the map.

Protected property OnDragStart: TNotifyEvent read FOnDragStart write FOnDragStart;

This event is fired when the user starts dragging the map.

Protected property OnIntervalEventsChange: TNotifyEvent read FOnIntervalEventsChange write FOnIntervalEventsChange;

OnIntervalEventsChange event is fired when IntervalEvents property value changes.

Protected property OnMapTypeIdChanged: TGMMapTypeIdChangedEvent read FOnMapTypeIdChanged write FOnMapTypeIdChanged;

This event is fired whenever the user's mouse moves over the map container.

See TGMMapTypeIdChangedEvent for more info.

Protected property OnMouseMove: TGMLatLngEvent read FOnMouseMove write FOnMouseMove;

This event is fired whenever the user's mouse moves over the map container.

See TGMLatLngEvent for more info.

Protected property OnMouseOut: TGMLatLngEvent read FOnMouseOut write FOnMouseOut;

This event is fired when the user's mouse exits the map container.

See TGMLatLngEvent for more info.

Protected property OnMouseOver: TGMLatLngEvent read FOnMouseOver write FOnMouseOver;

This event is fired when the user's mouse enters the map container.

See TGMLatLngEvent for more info.

Protected property OnPrecisionChange: TNotifyEvent read FOnPrecisionChange write FOnPrecisionChange;

OnPrecisionChange event is fired when Precision property value changes.

Protected property OnPropertyChanges: TGMPropertyChangesEvent read FOnPropertyChanges write FOnPropertyChanges;

Event fired when a property from and object changes.

Parameters
Owner
Owner of property.
PropName
Property name.
Protected property OnZoomChanged: TGMZoomChangedEvent read FOnZoomChanged write FOnZoomChanged;

This event is fired when the map zoom property changes.

See TGMZoomChangedEvent for more info.

Public property Precision: Integer read FPrecision write SetPrecision default 0;

Precision for lat and lng values.

Possibles values:
0 => Max precision
1..17 => Decimal precision

Protected property TrafficLayer: TGMTrafficLayer read FTrafficLayer write FTrafficLayer;

Class for google.maps.TrafficLayer class.

More information at google.maps.TrafficLayer class

Protected property TransitLayer: TGMTransitLayer read FTransitLayer write FTransitLayer;

Class for google.maps.TransitLayer class.

More information at google.maps.TransitLayer class


Generated by PasDoc 0.15.0.