Skip to content

Showing the map ​

Showing and hiding ​

The map is not loaded until you ask for it (MapVisible is False at start). These calls show it:

CallWhat it does
GotoAddress(Address)Shows the map at an address (looked up with the Google geocoding service) and puts a marker on it. An empty address hides the map
GotoLocation(LatLng, AAddMarker)Shows the map at a position; the marker is added unless AAddMarker is False. A position of 0, 0 hides the map
ShowMap(Address) / ShowMap(LatLng)Shows the map, at an address or at a position
HideMapClears the map (the page goes back to about:blank)

GotoAddress and GotoLocation can be called again and again: when the map is already visible they move it, without loading the page once more. The methods that draw on the map (markers, shapes) show it first if it is hidden, and wait until it is ready.

A position is a TLatLng record, with Latitude, Longitude and an optional Description that becomes the text of the marker. The two class functions TextToCoord and CoordToText convert a coordinate from and to text, always with the dot as decimal separator, whatever the regional settings of the machine.

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

View mode and zoom ​

pascal
EdgeGoogleMapViewer.MapTypeId := mtHYBRID;
EdgeGoogleMapViewer.MapZoom := 12;
MapTypeId
mtROADMAPThe default road map
mtSATELLITESatellite images
mtHYBRIDSatellite images with the roads and the names
mtTERRAINA physical map of the terrain

MapZoom is the zoom level (15 by default). When the user zooms the map, the OnMapZoom event tells you the new value.

Layers ​

PropertyMethod
MapShowTrafficLayerShowTraffic(Boolean)
MapShowBicyclingLayerShowBicycling(Boolean)

The property sets the value to use when the map is shown; the method changes it on the map that is on screen. Setting the property while the map is visible does both.

Hybrid view with the traffic layer

Controls ​

Every control of the map can be shown or hidden:

PropertyDefaultMethod
MapShowZoomControlTrueShowZoomControl
MapShowTypeControlTrueShowMapTypeControl
MapShowFullScreenControlTrueShowFullScreenControl
MapShowStreetViewControlFalseShowStreetViewControl
MapShowPanControlTrue
MapShowScaleControlTrue
MapShowoverviewMapControlTrue

When the map goes full screen the form around it usually has to give up its space: the OnContainsFullScreenElementChanged event of the browser tells you so, and the demo hides its panels in it.

Colour scheme ​

pascal
EdgeGoogleMapViewer.MapColorScheme := csDARK;   // or csLIGHT

The light and dark themes of the map. Changing it while the map is visible creates the map again, so a marker put before is no longer there.

Printing ​

ShowPrintUI opens the print panel of the browser, embedded in the form: the user can print the map as it is on screen.

The print panel

Released under the Apache License 2.0