Frequently Asked Component Specific Questions

Options

Display all FAQ items

Search FAQ items:


Displaying items 1 to 1 of 1, page 1 of 1

<< previous next >>

TMS VCL WebGMaps
Getting started

From the component palette, select TWebGMaps and drop it on a form. This shows an empty map. The map is only displayed when WebGMaps.Launch is called. The default center location displayed when WebGMaps.Launch is called is set by:

WebGMaps.MapOptions.DefaultLongitude
WebGMaps.MapOptions.DefaultLatitude

Markers can be added to the map by adding a new entry to the collection WebGMaps.Markers and setting the Marker's properties Longitude & Latitude.

This code snippet sets up the default view of the TWebGMaps to show the Los Angeles Theatre on Broadway at zoom level 19 with coordinates retrieved from the TWebGMapsGeocoding component:
begin
  WebGMapsGeocoding1.Address := 'Broadway 615, LOS ANGELES, USA';
  if WebGMapsGeocoding1.LaunchGeocoding = erOk then
  begin
    // center the map at the coordinate
    WebGMaps1.MapOptions.DefaultLatitude := WebGMapsGeocoding1.ResultLatitude;
    WebGMaps1.MapOptions.DefaultLongitude :=  WebGMapsGeocoding1.ResultLongitude;
    // Add a marker for the Los Angeles theatre
    WebGmaps1.Markers.Add(WebGMapsGeocoding1.ResultLatitude, 
    WebGMapsGeocoding1.ResultLongitude,'Broadway theatre');
    // set zoom level
    WebGmaps1.MapOptions.ZoomMap := 19;
    // launch the display of the map
    WebGMaps1.Launch;
  end;
end;
Further to this, we can take a look at the Los Angeles theatre by switching the map to StreetView. Following code snippet makes this switch when a checkbox is clicked:
procedure TForm1.CheckBox1Click(Sender: TObject);
begin
  if checkbox1.Checked then
    WebGmaps1.SwitchToStreetView
  else
    WebGmaps1.SwitchToMap;
end;