Skip to content

The demo ​

The demo shows every feature of the component at work: a form with the map in the middle, the parameters above and a table of customers below. It is the quickest way to see what a call does, and its code is the model for yours. It is in the repository, under Demo\GoogleMaps.

ProjectDelphiWhat it is
Demo\GoogleMaps\GoogleMapsTest.dproj10.4.2 → 13The demo, VCL, 32 and 64 bit

Open it, build (32 or 64 bit) and run. WebView2Loader.dll has to be next to the executable: the copies are in Demo\GoogleMaps\Bin\Win32 and Bin\Win64.

You need a Google API key

The map does not show without one. The demo registers its key in the initialization section of MainForm.pas through TEdgeGoogleMapViewer.RegisterGoogleMapsApiKey: put your own there (see Quick Start) before you run it.

What is on the form ​

AreaWhat it doesMethods and properties
Map AttributesView mode, zoom, "Center on click", the map controls (traffic, bicycling, street view, zoom, full screen, map type), light or dark colour schemeMapTypeId, MapZoom, ShowTraffic, ShowBicycling, ShowStreetViewControl, MapShowZoomControl, MapShowTypeControl, MapShowFullScreenControl, MapColorScheme
LocationGoes to an address or to a latitude / longitudeGotoAddress, GotoLocation
RoutingStart and destination as addresses or coordinates, travel mode, directions panelRouteByAddresses, RouteByLocations, MapRouteModeId, MapShowDirectionsPanel
DrawingTabs for markers, circles, polylines, polygons and the distance between two pointsPutMarker, PutMarkerByAddress, PutCircle, PutPolyline, PutPolygon, ComputeDistanceBetween
Buttons belowAnother form with a second map, print panel, show and hide the map, load the customersShowPrintUI, ShowMap, HideMap

The tour ​

Go to an address ​

Type an address and click Go to Address: the map moves there and puts a marker.

Go to an address

pascal
EdgeGoogleMapViewer.GotoAddress(MemoAddress.Lines.Text);

Go to a latitude and longitude ​

Type the coordinates (25.767314 / -80.135694) and click Go to Latitude Longitude.

Go to a latitude and longitude

pascal
Location.Latitude := TEdgeGoogleMapViewer.TextToCoord(Latitude.Text);
Location.Longitude := TEdgeGoogleMapViewer.TextToCoord(Longitude.Text);
EdgeGoogleMapViewer.GotoLocation(Location);

Route by bicycle, on the road map ​

Select the mode BICYCLING and the view ROADMAP, then Route by locations.

Route by bicycle

Route by addresses, hybrid view with traffic ​

Select the view HYBRID, activate Traffic and click Route by Addresses.

Route by addresses, hybrid with traffic

Route with the directions panel ​

Check Direction panel and click Route by Addresses: the steps appear next to the map.

Route with the directions panel

pascal
EdgeGoogleMapViewer.MapShowDirectionsPanel := CheckBoxDirectionPanel.Checked;
EdgeGoogleMapViewer.MapStartAddress := StartAddressMemo.Lines.Text;
EdgeGoogleMapViewer.MapDestinationAddress := DestinationAddressMemo.Lines.Text;
EdgeGoogleMapViewer.RouteByAddresses;

The print panel ​

Show Print UI opens the print panel of the browser inside the form.

The print panel

Markers from a table of customers ​

Load Table reads Data\customer.xml into a client dataset shown in the grid. For every record the grid scrolls to, the address is built from the fields and the map goes there; zoom out to see them all.

The markers of the customers

pascal
procedure TformMain.cdsCustomersAfterScroll(DataSet: TDataSet);
begin
  // ... Address is built from Addr1, Addr2, City, State and Country ...
  MemoAddress.Lines.Text := Address;
  if EdgeGoogleMapViewer.MapVisible then
    EdgeGoogleMapViewer.GotoAddress(Address);
end;

What is not in the screenshots ​

The pictures above come from an earlier version of the demo. Since version 2.0 it also has the Color Scheme selector (light and dark maps), the By Address tab of the markers (PutMarkerByAddress), the Custom Marker tab and the tabs of the circles, polylines and polygons with their style: see Markers and Circles, lines and polygons.

A second map ​

Show another form... opens SecondaryForm, with its own viewer: the component can be on several forms at once, and they share the key and the temporary folder registered at start.

Released under the Apache License 2.0