Skip to main content
Table of Contents

TTMSFNCGoogleMaps.AddKMLLayer Method

Adds a KML layer to the map.

API unit family: TMSFNCGoogleMaps Declaring type: TTMSFNCGoogleMaps Inherited from: TTMSFNCCustomGoogleMaps

Syntax

FMX.TMSFNCGoogleMaps.hppPascalC++
function AddKMLLayer(AURL: string; AZoomToBounds: Boolean = True; ASuppressInfoWindows: Boolean = False): TTMSFNCGoogleMapsKMLLayer;
TTMSFNCGoogleMapsKMLLayer* __fastcall AddKMLLayer(System::UnicodeString AURL, bool AZoomToBounds = true, bool ASuppressInfoWindows = false);

Parameters

Name Description
AURL URL used by the operation.
AZoomToBounds When True, the map zooms to the layer bounds.
ASuppressInfoWindows When True, KML info windows are suppressed.

Returns

The resulting google maps kml layer instance.

Usage examples

Add a KML layer and handle layer clicks

Calls AddKMLLayer with the SuppressInfoWindows parameter and wires OnKMLLayerClick.

Add a KML layer and handle layer clicksPascalC++
procedure TForm1.ConfigureGoogleMapsKMLLayer;
begin
  TMSFNCGoogleMaps1.ClearKMLLayers;
  TMSFNCGoogleMaps1.AddKMLLayer(
    'https://developers.google.com/maps/documentation/javascript/examples/kml/westcampus.kml',
    True,
    True);
  TMSFNCGoogleMaps1.OnKMLLayerClick := TMSFNCGoogleMaps1KMLLayerClick;
end;

procedure TForm1.TMSFNCGoogleMaps1KMLLayerClick(Sender: TObject;
  AEventData: TTMSFNCMapsEventData);
begin
  { Inspect AEventData.ID or AEventData.Coordinate and show your own detail UI. }
end;
void __fastcall TForm1::ConfigureGoogleMapsKMLLayer()
{
  TMSFNCGoogleMaps1->ClearKMLLayers();
  TMSFNCGoogleMaps1->AddKMLLayer(
    "https://developers.google.com/maps/documentation/javascript/examples/kml/westcampus.kml",
    true,
    true);
  TMSFNCGoogleMaps1->OnKMLLayerClick = TMSFNCGoogleMaps1KMLLayerClick;
}

void __fastcall TForm1::TMSFNCGoogleMaps1KMLLayerClick(TObject *Sender,
  TTMSFNCMapsEventData *AEventData)
{
  // Inspect AEventData->ID or AEventData->Coordinate and show your own detail UI.
}

Read the related guide