TEdgeGoogleMapViewer
Unit Vcl.GoogleMap. A descendant of TCustomEdgeBrowser: everything the browser publishes (Align, Anchors, PopupMenu, UserDataFolder, the On... events of WebView2...) is there too. This page lists what the component adds.
Types
pascal
TLatLng = record
Latitude: Double;
Longitude: Double;
Description: string;
end;
TGoogleMapTypeId = (mtROADMAP, mtSATELLITE, mtHYBRID, mtTERRAIN);
TGoogleRouteModeId = (rmDRIVING, rmWALKING, rmBICYCLING, rmTRANSIT);
TGoogleMarkerAnimationId = (maNONE, maBOUNCE, maDROP);
TGoogleMapColorScheme = (csLIGHT, csDARK);EGoogleMapError is the exception the component raises.
Properties
Map
| Property | Type | Default | |
|---|---|---|---|
MapAPIKey | string | The Google API key; it sets the key shared by all the viewers | |
MapVisible | Boolean | False | The map is shown; setting it shows or hides it |
MapAddress | string | The address of the map; assigning it while the map is visible moves it there | |
MapLatitude, MapLongitude | Double | The centre of the map | |
MapLocationDesc | string | The text of the marker at the centre | |
MapZoom | Integer | 15 | The zoom level |
MapTypeId | TGoogleMapTypeId | mtROADMAP | The view mode |
MapColorScheme | TGoogleMapColorScheme | csLIGHT | Light or dark map (recreates the map) |
MapShowTrafficLayer | Boolean | False | The traffic layer |
MapShowBicyclingLayer | Boolean | False | The bicycling layer |
Controls
| Property | Default |
|---|---|
MapShowPanControl | True |
MapShowZoomControl | True |
MapShowTypeControl | True |
MapShowScaleControl | True |
MapShowFullScreenControl | True |
MapShowStreetViewControl | False |
MapShowoverviewMapControl | True |
Routing
| Property | Type | Default |
|---|---|---|
MapStartAddress, MapDestinationAddress | string | |
MapStartLatitude, MapStartLongitude | Double | |
MapDestinationLatitude, MapDestinationLongitude | Double | |
MapRouteModeId | TGoogleRouteModeId | rmDRIVING |
MapShowDirectionsPanel | Boolean | False |
Class methods
| Method | |
|---|---|
RegisterGoogleMapsApiKey(AApiKey) | Registers the Google API key, for every viewer |
RegisterUserDataFolder(AFolder) | Registers the folder where WebView2 keeps its data |
TextToCoord(Text): Extended | A coordinate from text, with the dot as decimal separator |
CoordToText(Coord): string | A coordinate as text, with six decimals and the dot as separator |
JSQuotedStr(Value): string | A string as a JavaScript string literal |
ApiKey is a read-only class property with the registered key.
Methods
Showing the map
| Method | |
|---|---|
GotoAddress(Address) | Shows the map at an address, with a marker |
GotoLocation(LatLng, AAddMarker = True) | Shows the map at a position |
ShowMap(Address), ShowMap(AMapCenter, AAddress = '') | Shows the map |
HideMap | Hides the map |
ShowPrintUI | Opens the print panel of the browser |
NavigateToURL(URL) | Navigates the browser to an address |
Layers and controls
ShowTraffic, ShowBicycling, ShowStreetViewControl, ShowZoomControl, ShowMapTypeControl, ShowFullScreenControl and ShowDirectionsPanel, each with a Boolean.
Markers
| Method | |
|---|---|
PutMarker(LatLng, ADescription, AAnimation, ALabel, AInfoWindowContent, ACustomMarkerJSON) | Puts a marker |
PutMarker(LatLng, ADescription, AInfoTitle, AAnimation, ALabel, AInfoWindowContent, ACustomMarkerJSON) | The same, with the title of the info window |
PutMarkerByAddress(AAddress, AInfoTitle, AInfoWindowContent) | A marker at an address |
ClearMarkers, HideMarkers, ShowMarkers | Remove, hide and show every marker |
DefaultCustomMarkerJSON: string | An example of a custom marker |
Shapes
| Method | |
|---|---|
PutCircle(LatLng, Radius, Editable, Draggable, Visible, Clickable, StrokeColor, StrokeOpacity, StrokeWeight, FillColor, FillOpacity, AInfoWindowContent) | Puts a circle |
PutPolyline(Path, Geodesic, Editable, Visible, Clickable, FitBounds, StrokeColor, StrokeOpacity, StrokeWeight, AInfoWindowContent) | Puts a polyline |
PutPolygon(Path, Editable, Visible, Clickable, FitBounds, StrokeColor, StrokeOpacity, StrokeWeight, FillColor, FillOpacity, AInfoWindowContent) | Puts a polygon |
ClearCircles, HideCircles, ShowCircles | |
ClearPolylines, HidePolylines, ShowPolylines | |
ClearPolygons, HidePolygons, ShowPolygons | |
ComputeDistanceBetween(Origin, Destination): Double | The distance in meters |
Routing
RouteByAddresses and RouteByLocations.
Events
| Event | Type | |
|---|---|---|
OnMapClick, OnMapRightClick | procedure(ASender: TObject; ALatLng: TLatLng) | A click and a right click on the map |
OnMapZoom | procedure(ASender: TObject; AZoom: Integer) | The zoom has changed |
BeforeInitMap | TNotifyEvent | Before the browser is initialised |
BeforeShowMap | TNotifyEvent | Before the map is shown |
AfterHideMap | TNotifyEvent | After the map has been hidden |
OnGetJavascript | procedure(ASender: TObject; var AJavascript: string) | The script of the page, to add to it |
OnGetHTMLBody | procedure(ASender: TObject; var AHTML: string) | The body of the page, to change it |
OnWebUnhandledMessageReceived | TWebMessageReceivedEvent | A message of the page that the component does not know |
See Events and clicks and How it works.