Map
Description
Allows you to place an interactive geographical map of Google Maps on the form, with the ability to put on the map markers, lines and polygons (placing lines and polygons is done using scripts.).
Class: TdbMap
Properties
Property |
Type |
Description |
APIKey |
String |
Optionally specify an API Key to identify the application with the Google Maps API. |
APIChannel |
String |
Optionally specify a Channel ID to identify the application with the Google Maps Premium API. This value is ignored if an API Key value is specified. |
APIClientID |
String |
Optionally specify a Client ID to identify the application with the Google Maps Premium API. This value is ignored if an API Key value is specified. |
APISignature |
String |
Optionally specify an API Signature to identify the application with the Google Maps Premium API. |
APIClientAuthURL |
String |
Optionally specify the authenticated URL as specified on the Google Maps Premium console. The Default URL is: http://127.0.0.1. This value is ignored if an API Key value is specified. |
CurrentLocation |
TLocation |
Contains the coordinates of the user's location. For these coordinates to be available, you must first call the GetCurrentLocation method. It does not work temporarily. |
dbTable |
String |
Determines which database table a component belongs to. |
dbFieldLatitude |
String |
Specifies in which field of the database table the latitude value of the marker will be stored. |
dbFieldLongitude |
String |
Specifies in which field of the database table the longitude value of the marker will be stored. |
DisableMenu |
Boolean |
Allows you to disable the map context menu. |
Elevations |
TElevations |
Contains the result of calling the GetElevation and GetElevation2 method. Allows to find the height of the ground surface at the specified coordinates. |
FormMarkerName |
String |
Specifies the name of the form that will be used when creating/editing the marker. |
LastAddedMarker |
TMarker |
Contains a reference to the last added marker using the method: TMarkers.Add (Form1.Map1.Markers.Add) |
LastAddedPolyline |
TPolylineItem |
Contains a reference to the last added path using the method: TPolylines.Add (Form1.Map1.Polylines.Add) |
LastAddedPolygon |
TPolygonItem |
Contains a reference to the last polygon added using the method: TPolygons.Add (Form1.Map1.Polygons.Add) |
TMarkers |
Property for working with markers on the map. More info. |
|
TMarker |
Property to access existing markers on the map. More info. |
|
TMapOptions |
Setting up the component. More info. |
|
TPolylines |
Property for working with polylines on the map. More info. |
|
TPolylineItem |
Property to access existing polylines on the map. More info. |
|
TPolygons |
Property for working with polygons on the map. More info. |
|
TPolygonItem |
Property to access existing polygons on the map. More info. |
|
Enabled |
Boolean |
Controls whether the component responds to mouse, keyboard, and timer events. |
Name |
String |
The name of the component. |
Visible |
Boolean |
Specifies whether the component appears onscreen. |
Left |
Integer |
Specifies the horizontal coordinate of the left edge of a component relative to its parent. |
Top |
Integer |
Specifies the vertical coordinate of the upper-left of a component relative to its parent. |
Width |
Integer |
Specifies the horizontal size of the component in pixels. |
Height |
Integer |
Specifies the vertical size of the component in pixels. |
Tag |
Integer |
Allows you to assign a number to a component for your own needs. |
TagString |
String |
Allows you to assign a string to a component for your own needs. |
Methods
Method |
Description |
function AddGeoImage (FileName: string; Title: string = ''; Width: Integer = -1; Height: Integer = -1; ZoomWidth: Integer = -1; ZoomHeight: Integer = -1): TMarker |
This function retrieves the geo coordinates that are found in the exif data of the image file specified in the FileName parameter and adds a Marker to the map at that location with the image file as its icon. Use the optional Width, Height, ZoomWidth and ZoomHeight parameters to specify a custom size for the marker icon. |
function AddMapKMLLayer (Url: string; ZoomToBounds: Boolean): Boolean |
This function displays a KML file on the map as defined by the Url parameter. If the ZoomToBounds is true the map is zoomed to the bounding box of the contents of the layer. |
function ClearPolygons: Boolean |
Remove all polygons from the map and clear the Polygons collection. |
function ClearPolylines: Boolean |
Remove all polylines from the map and clear the Polylines collection. |
function CloseMarkerInfoWindowHtml (Id: Integer): Boolean |
The function closes the information windows of the marker with the given marker-id (Marker.Index). |
procedure CloseAllMarkersInfoWindow |
Closes the information windows for all markers. |
function CreateMapPolygon (Polygon: TMapPolygon): Boolean |
Puts the specified polygon on the map. |
function CreateMapPolyline (Polyline: TPolyline): Boolean |
Puts the specified polyline on the map. |
function DegreesToLonLat (StrLon, StrLat: String; var Lon,Lat: Double): Boolean |
This function converts degrees to longitude / latitude coordinates. More info. |
function DeleteAllMapKMLLayer: Boolean |
This function removes all KML layers from the map. |
function DeleteMapKMLLayer (Id: Integer): Boolean |
The function removes a KML layer from the map. |
function DeleteMapMarker (Id: Integer): Boolean |
Deletes the specified marker from the map. The marker is not removed from the collection TMarkers |
function DeleteMapPolyline (Id: Integer): Boolean |
Deletes the specified polyline from the map. The polyline is not removed from the collection TPolylines |
function DeleteMapPolygon (Id: Integer): Boolean |
Deletes the specified polygon from the map. The polygon is not removed from the collection TPolygons |
function Distance (la1, lo1, la2, lo2: Double): Double |
Calculates the distance between two coordinates. The result is in kilometers. |
function Focused: Boolean |
Determines whether the control has input focus. |
function GetCurrentLocation: Boolean |
Sets the CurrentLocation.Latitude and CurrentLocation.Longitude to the coordinates of the current location. It does not work temporarily. |
function GetMapBounds: Boolean |
This function retrieves the bounds coordinates of the currently displayed map. The bounds are returned via the OnBoundsRetrieved event. Doesn't work in the current version. |
function GetElevation (Latitude, Longitude: Double): Boolean |
Retrieves the elevation data for a single latitude and longitude coordinate. The data is added to the Elevations collection. Returns true if the request succeeded, false otherwise. Maps Elevation API activation is required. More info. |
function GetElevation2 (Path: TPath; ResultCount: Integer = 2): Boolean |
Retrieves the elevation data for a Path that contains latitude and longitude coordinates. The start location (first coordinate in Path) and end location (last coordinate in path) are used to form a straight line. The elevation data is retrieved along the straight path at specified intervals. The number of intervals is indicated by the ResultCount parameter. The data is added to the Elevations collection. Returns true if the request succeeded, false otherwise. Maps Elevation API activation is required. More info. |
function GetModifiedMapPolyline (Polyline: TPolyline):Boolean |
This function retrieves modified coordinates from a Polyline on the map and updates the Polyline.Path values. Typically used when the user modifies lines on the map with the mouse and the result of these changes must be applied. |
function GetModifiedMapPolygon (Polygon: TMapPolygon):Boolean |
This function retrieves modified coordinates from a Polygon on the map and updates the Polygon values. (This includes the Path values for a Polygon of type ptPath, the Center and Radius values for Polygon of type ptCircle and the Bounds values for a Polygon of type ptRectangle) Typically used when the user modifies polygons on the map with the mouse and the result of these changes must be applied. |
function GetPolygonAreaSqMeters (APolygonId: Integer): string |
Returns the area in square meters for the specified polygon. |
function LoadGeoJSONPolyline (AFilename: string; AColor: TColor = clBlue; Opacity: Integer = 255; AWidth: Integer = 2; Zoom: Boolean = True; HoverColor: TColor = clBlue): string |
This function loads coordinates from a GEOJSON file and displays it on the map as a Polyline or Polylines. Optionally set the Color, Opacity, Width, HoverColor of the Polyline(s). Optionally set Zoom to true to automatically zoom the map to the bounds of the Polyline(s). More info. |
function LoadGeoJSONPolygon (AFilename: string; BorderColor: TColor = clBlue; Opacity: Integer = 255; BackgroundColor: TColor = clBlue; BackgroundOpacity: Integer = 100; AWidth: Integer = 2; Zoom: Boolean = True; HoverBorderColor: TColor = clBlue; HoverBackgroundColor: TColor = clBlue): string |
This function loads coordinates from a GEOJSON file and displays it on the map as a Polygon or Polygons. Optionally set the BorderColor, Opacity, BackgroundColor, BackgroundOpacity, Width, HoverBorderColor, HoverBackgroundColor of the Polygon(s). Optionally set Zoom to true to automatically zoom the map to the bounds of the Polygon(s). More info. |
function LoadGPSRoute (AFilename: string; AColor: TColor = clRed; AWidth: integer = 2; ZoomToRoute: Boolean = False): string |
This function loads a GPS route from a GPX file and displays it on the map as a Polyline. More info about GPX file. |
procedure LoadMarkersFromPoi (PoiFile: string; MarkerColor: TMarkerIconColor = icDefault) |
This functions loads a set of coordinates from the POI file specified in PoiFile and automatically adds them to the map as markers. Optionally the color of the markers can be specified with MarkerColor. |
function LonLatToXY (Lon, Lat: Double; var X, Y: Integer): Boolean |
This function converts longitude / latitude coordinates to XY coordinates. Returns the X and Y pixel coordinates in the control window of the latitude and longitude coordinates. |
function MapPanTo (Latitude,Longitude:Double): Boolean |
This function performs a pan to a location set by latitude and longitude coordinates. This is useful to set a certain position in the center of the control canvas. |
function MapZoomTo (Bounds: TBounds): Boolean |
This function performs a zoom to fit the map inside the given bounds coordinates. More info. |
function MapPanBy (X,Y: Integer): Boolean |
The function moves the map horizontally (x) and vertical (y) pixels. |
function OpenMarkerInfoWindowHtml (Id: Integer; HtmlText:String): Boolean |
The function opens the marker info window for the marker with selected marker-id (Marker.Index). Extra information can be passed via the HtmlText string. More info. |
procedure SaveMarkersToPoi (PoiFile: string) |
This functions saves the coordinates of all markers to the POI file specified in PoiFile. |
function ScreenShot (ImgType: TImgType): TGraphic |
The function takes a screenshot of the actual map canvas. This screenshot is taken in the chosen imagetype: itJPeg, itBitmap or itPng. More info. |
procedure SetFocus |
Gives the input focus to the component. |
procedure SwitchToStreetView |
Switches the map to the panoramic street view. |
procedure SwitchToMap |
Exit the panoramic street view mode. |
function UpdateMapMarkers: Boolean |
Updates all markers on the map. |
function UpdateMapMarker (Marker: TMarker):Boolean |
Updates the specified marker on the map. |
function UpdateMapPolygon (Polygon: TMapPolygon): Boolean |
Updates the specified polygon on the map. It should be called, for example, when you have updated the coordinates of a polygon with a script. |
function UpdateMapPolyline (Polyline: TPolyline): Boolean |
Updates the specified polyline on the map. It should be called when, for example, you have updated the coordinates of the polyline with a script. |
function XYToLonLat (X, Y: integer; var Lon, Lat: double): Boolean |
This function converts XY coordinates to longitude / latitude coordinates. Returns the latitude and longitude coordinates of the X and Y pixel coordinates in the control window. |
Events
Event |
Description |
OnMapClick (Sender: TObject; Latitude, Longitude: Double; X, Y: Integer; MouseLeft, MouseRight, MouseMiddle: Boolean) |
Occurs when the map is clicked. Returns the latitude and longitude coordinates of that position, the X and Y values indicate the pixel coordinates in the control window, button parameter returns what button was clicked on the mouse. |
OnMapDblClick (Sender: TObject; Latitude, Longitude: Double; X, Y: Integer) |
Occurs when the user double-clicks the left mouse button when the mouse pointer is over the component. Returns the latitude and longitude coordinates of the mouse cursor position, the X and Y values indicate the pixel position of the mouse cursor in the control window. |
OnMapMouseEnter (Sender: TObject; Latitude, Longitude: Double; X, Y: Integer) |
Occurs when the user moves the mouse into a component. Returns the latitude and longitude coordinates of the mouse cursor position, the X and Y values indicate the pixel position of the mouse cursor in the control window. |
OnMapMouseExit (Sender: TObject; Latitude, Longitude: Double; X, Y: Integer) |
Occurs when the user moves the mouse outside of a component. Returns the latitude and longitude coordinates of the mouse cursor position, the X and Y values indicate the pixel position of the mouse cursor in the control window. |
OnMapMouseMove (Sender: TObject; Latitude, Longitude: Double; X, Y: Integer) |
Occurs when the user moves the mouse pointer while the mouse pointer is over a component. Returns the latitude and longitude coordinates of the mouse cursor position, the X and Y values indicate the pixel position of the mouse cursor in the control window. |
OnMapMove (Sender: TObject; Latitude, Longitude: Double; X, Y: Integer) |
Occurs when the entire map is moved (left mouse and drag) within the control. Returns the latitude and longitude coordinates of the mouse cursor position, the X and Y values indicate the pixel position of the mouse cursor in the control window. |
OnMapMoveEnd (Sender: TObject; Latitude, Longitude: Double; X, Y: Integer) |
Occurs at the end of an entire map move (left mouse and drag) within the control. Returns the latitude and longitude coordinates of that position, the X and Y values indicate the pixel position in the control window. |
OnMapMoveStart (Sender: TObject; Latitude, Longitude: Double; X, Y: Integer) |
Occurs at the start of an entire map move (left mouse and drag) within the control. Returns the latitude and longitude coordinates of that position, the X and Y values indicate the pixel position in the control window. |
OnMapTypeChange (Sender: TObject; NewMapType: TMapType) |
Occurs when the map type is changed. This event returns the selected map type. |
OnMapZoomChange (Sender: TObject; NewLevel: Integer) |
Occurs when the zoom level is changed via any type of the zoom control. The event returns the selected zoom level. |
OnMarkerClick (Sender: TObject; MarkerTitle: string; IdMarker: Integer; Latitude, Longitude: Double; MouseLeft, MouseRight, MouseMiddle: Boolean) |
Occurs when a marker is clicked. Returns the marker title, the marker id, latitude and longitude coordinates defined for the marker, and what button has been clicked on the mouse. |
OnMarkerDblClick (Sender: TObject; MarkerTitle: string; IdMarker: Integer; Latitude, Longitude: Double) |
Occurs when a marker is double-clicked. The event returns the marker title, the marker id, latitude and longitude coordinates of the selected marker. |
OnMarkerDrag (Sender: TObject; MarkerTitle: string; IdMarker: Integer; Latitude, Longitude: Double) |
Occurs when a marker is dragged around the control. The event returns the marker title, the marker id, latitude and longitude coordinates of the selected marker. |
OnMarkerDragEnd (Sender: TObject; MarkerTitle: string; IdMarker: Integer; Latitude, Longitude: Double) |
Occurs at the end of when a marker is dragged in the control. The event returns the marker title, the marker id, latitude and longitude coordinates of the selected marker. |
OnMarkerDragStart (Sender: TObject; MarkerTitle: string; IdMarker: Integer; Latitude, Longitude: Double) |
Occurs at the start of when a marker is dragged in the control. The event returns the marker title, marker id, latitude and longitude coordinates of the selected marker. |
OnMarkerInfoWindowCloseClick (Sender: TObject; IdMarker: Integer) |
Occurs when the info window is closed. The event returns the marker id. |
OnMarkerMouseDown (Sender: TObject; MarkerTitle: string; IdMarker: Integer; Latitude, Longitude: Double) |
Occurs when the mouse cursor is over a marker and a mouse button is pressed. The event returns the marker title, marker id, latitude and longitude coordinates of the selected marker. |
OnMarkerMouseEnter (Sender: TObject; MarkerTitle: string; IdMarker: Integer; Latitude, Longitude: Double) |
Occurs when the mouse cursor enters a marker. The event returns the marker title, marker id, latitude and longitude coordinates for that position. |
OnMarkerMouseExit (Sender: TObject; MarkerTitle: string; IdMarker: Integer; Latitude, Longitude: Double) |
Occurs when the mouse cursor leaves the marker. The event returns the latitude and longitude coordinates of that position the X and Y values indicate the pixel position in the control window. |
OnMarkerMouseUp (Sender: TObject; MarkerTitle: string; IdMarker: Integer; Latitude, Longitude: Double) |
Occurs when the mouse cursor is over a marker and a mouse button is released. The event returns the marker title, marker id, latitude and longitude coordinates of the selected marker. |
OnAfterAddMarker (Sender: TObject; IdMarker: Integer) |
Occurs after adding a marker. The event will not occurs if the marker was added using a script. |
OnBeforeDeleteMarker (Sender: TObject; IdMarker: Integer; var Cancel: Boolean) |
Occurs before the marker is deleted, with the ability to prevent the deletion. The event will not occur if the marker is deleted using a script. |
OnPolygonClick (Sender: TObject; IdPolygon: Integer; MouseLeft, MouseRight, MouseMiddle: Boolean) |
Occurs when a polygon is clicked. Returns the polygon id and what button has been clicked on the mouse. |
OnPolygonDblClick (Sender: TObject; IdPolygon: Integer) |
Occurs when a polygon is double-clicked. The event returns the polygon id. |
OnPolygonMouseDown (Sender: TObject; IdPolygon: Integer) |
Occurs when the mouse cursor is over a polygon and a mouse button is pressed. The event returns the polygon id. |
OnPolygonMouseEnter (Sender: TObject; IdPolygon: Integer) |
Occurs when the mouse cursor enters a polygon. The event returns the polygon id. |
OnPolygonMouseExit (Sender: TObject; IdPolygon: Integer) |
Occurs when the mouse cursor leaves a polygon. The event returns polygon id. |
OnPolygonMouseUp (Sender: TObject; IdPolygon: Integer) |
Occurs when the mouse cursor is over a polygon and a mouse button is released. The event returns the polygon id. |
OnPolygonChanged (Sender: TObject; IdPolygon: Integer) |
Occurs when a polygon has been modified on the map. The event returns the polygon id. The modified coordinates can be retrieved with the GetModifiedPoygon method. |
OnPolylineClick (Sender: TObject; IdPolyline: Integer; MouseLeft, MouseRight, MouseMiddle: Boolean) |
Occurs when a polyline is clicked. Returns the polyline id and what button has been clicked on the mouse. |
OnPolylineDblClick (Sender: TObject; IdPolyline: Integer) |
Occurs when a polyline is double-clicked. The event returns the polyline id. |
OnPolylineMouseDown (Sender: TObject; IdPolyline: Integer) |
Occurs when the mouse cursor is over a polyline and a mouse button is pressed. The event returns the polyline id. |
OnPolylineMouseEnter (Sender: TObject; IdPolyline: Integer) |
Occurs when the mouse cursor enters a polyline. The event returns the polyline id. |
OnPolylineMouseExit (Sender: TObject; IdPolyline: Integer) |
Occurs when the mouse cursor leaves a polyline. The event returns polyline id. |
OnPolylineMouseUp (Sender: TObject; IdPolyline: Integer) |
Occurs when the mouse cursor is over a polyline and a mouse button is released. The event returns the polyline id. |
OnPolylineChanged (Sender: TObject; IdPolyline: Integer) |
Occurs when a polyline has been modified on the map. The event returns the polyline id. The modified coordinates can be retrieved with the GetModifiedPoyline method. |
OnStreetViewChange (Sender: TObject; Heading, Pitch, Zoom: Integer) |
Occurs when the Point Of View is changed while StreetView mode is active. Returns the Heading, Pitch and Zoom values. |
OnStreetViewMove (Sender: TObject; Latitude, Longitude: Double; X, Y: Integer) |
Occurs when the geographic position is changed while StreetView mode is active. Returns the latitude and longitude coordinates of that position, the X and Y values indicate the pixel position in the control window. |
OnWebGMapsError (Sender: TObject; ErrorType: TErrorType) |
Occurs when an error is received. This event returns the error type. |