Skip to content

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 ​

PropertyTypeDefault
MapAPIKeystringThe Google API key; it sets the key shared by all the viewers
MapVisibleBooleanFalseThe map is shown; setting it shows or hides it
MapAddressstringThe address of the map; assigning it while the map is visible moves it there
MapLatitude, MapLongitudeDoubleThe centre of the map
MapLocationDescstringThe text of the marker at the centre
MapZoomInteger15The zoom level
MapTypeIdTGoogleMapTypeIdmtROADMAPThe view mode
MapColorSchemeTGoogleMapColorSchemecsLIGHTLight or dark map (recreates the map)
MapShowTrafficLayerBooleanFalseThe traffic layer
MapShowBicyclingLayerBooleanFalseThe bicycling layer

Controls ​

PropertyDefault
MapShowPanControlTrue
MapShowZoomControlTrue
MapShowTypeControlTrue
MapShowScaleControlTrue
MapShowFullScreenControlTrue
MapShowStreetViewControlFalse
MapShowoverviewMapControlTrue

Routing ​

PropertyTypeDefault
MapStartAddress, MapDestinationAddressstring
MapStartLatitude, MapStartLongitudeDouble
MapDestinationLatitude, MapDestinationLongitudeDouble
MapRouteModeIdTGoogleRouteModeIdrmDRIVING
MapShowDirectionsPanelBooleanFalse

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): ExtendedA coordinate from text, with the dot as decimal separator
CoordToText(Coord): stringA coordinate as text, with six decimals and the dot as separator
JSQuotedStr(Value): stringA 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
HideMapHides the map
ShowPrintUIOpens 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, ShowMarkersRemove, hide and show every marker
DefaultCustomMarkerJSON: stringAn 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): DoubleThe distance in meters

Routing ​

RouteByAddresses and RouteByLocations.

Events ​

EventType
OnMapClick, OnMapRightClickprocedure(ASender: TObject; ALatLng: TLatLng)A click and a right click on the map
OnMapZoomprocedure(ASender: TObject; AZoom: Integer)The zoom has changed
BeforeInitMapTNotifyEventBefore the browser is initialised
BeforeShowMapTNotifyEventBefore the map is shown
AfterHideMapTNotifyEventAfter the map has been hidden
OnGetJavascriptprocedure(ASender: TObject; var AJavascript: string)The script of the page, to add to it
OnGetHTMLBodyprocedure(ASender: TObject; var AHTML: string)The body of the page, to change it
OnWebUnhandledMessageReceivedTWebMessageReceivedEventA message of the page that the component does not know

See Events and clicks and How it works.

Released under the Apache License 2.0