Skip to main content
Table of Contents

TTMSFNCOpenLayers Class

Provides an OpenLayers-based interactive map component.

API unit family: TMSFNCOpenLayers Inherits from: TTMSFNCCustomOpenLayers

Syntax

GeneratedPascalC++
TTMSFNCOpenLayers = class(TTMSFNCCustomOpenLayers)
class PASCALIMPLEMENTATION TTMSFNCOpenLayers : public TTMSFNCCustomOpenLayers

Properties

Name Description
Clusters Provides the marker cluster collection. (inherited from TTMSFNCCustomOpenLayers)
HeatMaps Provides the heat map collection. (inherited from TTMSFNCCustomOpenLayers)
Markers Provides the marker collection. (inherited from TTMSFNCCustomOpenLayers)
Options Provides access to map provider options. (inherited from TTMSFNCCustomOpenLayers)
Polygons Provides the polygon collection. (inherited from TTMSFNCCustomOpenLayers)
Polylines Provides the polyline collection. (inherited from TTMSFNCCustomOpenLayers)
TileLayers Provides the custom tile layer collection. (inherited from TTMSFNCCustomOpenLayers)

Methods

Name Description
AddBridge Adds an object bridge for browser script communication.
AddCircle Adds a circle to the map. (inherited from TTMSFNCCustomOpenLayers)
AddHeatMap Adds a heat map layer to the map. (inherited from TTMSFNCCustomOpenLayers)
AddMarker Adds a marker to the map. (inherited from TTMSFNCCustomOpenLayers)
AddPolygon Adds a polygon to the map. (inherited from TTMSFNCCustomOpenLayers)
AddPolyline Adds a polyline to the map. (inherited from TTMSFNCCustomOpenLayers)
AddRectangle Adds a rectangle to the map. (inherited from TTMSFNCCustomOpenLayers)
AddTileLayer Adds a custom tile layer to the map. (inherited from TTMSFNCCustomOpenLayers)
CanGoBack Returns whether the embedded browser can navigate back.
CanGoForward Returns whether the embedded browser can navigate forward.
CaptureScreenShot Captures a screenshot of the embedded browser.
Clear Removes all items from the collection. (inherited from TTMSFNCCustomOpenLayers)
ClearCache Clears the embedded browser cache.
ClearClusters Removes all marker clusters from the map. (inherited from TTMSFNCCustomOpenLayers)
ClearHeatMaps Removes all heat map layers from the map. (inherited from TTMSFNCCustomOpenLayers)
ClearTileLayers Removes all custom tile layers from the map. (inherited from TTMSFNCCustomOpenLayers)
DeInitialize Deinitializes the embedded browser and map runtime.
EndUpdate Ends an update block and applies pending map changes. (inherited from TTMSFNCCustomOpenLayers)
ExecuteJavaScript Executes JavaScript in the embedded map browser.
ExecuteJavaScriptSync Executes JavaScript synchronously in the embedded map browser.
GetBridgeCommunicationLayer Returns the script communication layer for a bridge.
GetWebBrowserInstance Returns the native web browser instance interface.
GoBack Navigates back in the embedded browser history.
GoForward Navigates forward in the embedded browser history.
Initialize Initializes the embedded browser and map runtime.
IsFMXBrowser Returns whether the active browser is the native FMX browser.
LoadFile Loads an HTML file into the embedded browser.
LoadHTML Loads HTML content into the embedded browser.
NativeBrowser Returns the native browser handle.
NativeDialog Returns the native dialog handle used by the browser.
NativeEnvironment Returns the native browser environment handle.
Navigate Navigates the embedded browser to the map document or URL.
Reload Reloads the embedded browser content.
RemoveBridge Removes an object bridge from browser script communication.
ShowDebugConsole Shows the browser debug console.
StopLoading Stops the current browser load operation.

Events

Name Description
OnClusterClick Occurs when a marker cluster is clicked. (inherited from TTMSFNCCustomOpenLayers)
OnMapRenderComplete Occurs when the map render cycle has completed. (inherited from TTMSFNCCustomOpenLayers)
OnMarkerDragEnd Occurs when marker dragging ends. (inherited from TTMSFNCCustomOpenLayers)
OnPolyElementDragEnd Occurs when dragging of a polygon or polyline element ends. (inherited from TTMSFNCCustomOpenLayers)

Usage examples

Combine OpenLayers versioning, layers, clusters, heat maps, and events

Builds an OpenLayers scene that combines several documented feature areas.

Combine OpenLayers versioning, layers, clusters, heat maps, and eventsPascal
procedure TForm1.BuildOpenLayersOperationsMap;
var
  LLayer: TTMSFNCOpenLayersTileLayer;
  LCluster: TTMSFNCOpenLayersCluster;
  LMarker: TTMSFNCOpenLayersMarker;
  LHeatMap: TTMSFNCOpenLayersHeatMap;
  LWeightedCoordinate: TTMSFNCMapsWeightedCoordinate;
begin
  TMSFNCOpenLayers1.BeginUpdate;
  try
    TMSFNCOpenLayers1.Options.Version := '10.9.0';
    TMSFNCOpenLayers1.Options.ShowBaseLayer := True;

    LLayer := TMSFNCOpenLayers1.AddTileLayer(
      'https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png', 1);
    LLayer.Source := tlsXYZ;
    LLayer.CSSClassName := 'operations-base-layer';

    LCluster := TMSFNCOpenLayers1.Clusters.Add;
    LCluster.FillColor := gcDarkgreen;
    LCluster.FontColor := gcWhite;
    LCluster.StrokeColor := gcWhite;

    LMarker := TMSFNCOpenLayers1.Markers.Add;
    LMarker.Coordinate.Latitude := 52.52;
    LMarker.Coordinate.Longitude := 13.405;
    LMarker.Title := 'Berlin depot';
    LMarker.DefaultAnchor := False;
    LMarker.Anchor.X := 14;
    LMarker.Anchor.Y := 30;
    LMarker.Cluster := LCluster;
    LCluster.Markers.Add(LMarker);

    LHeatMap := TMSFNCOpenLayers1.HeatMaps.Add;
    LHeatMap.Opacity := 0.45;
    LWeightedCoordinate := LHeatMap.WeightedCoordinates.Add;
    LWeightedCoordinate.Coordinate.Latitude := 52.52;
    LWeightedCoordinate.Coordinate.Longitude := 13.405;
    LWeightedCoordinate.Weight := 0.8;

    TMSFNCOpenLayers1.AddLabel(52.52, 13.405, 'Berlin depot', gcWhite, gcDarkgreen);

    TMSFNCOpenLayers1.OnMapRightClick := TMSFNCOpenLayers1MapRightClick;
    TMSFNCOpenLayers1.OnMarkerRightClick := TMSFNCOpenLayers1MarkerRightClick;
    TMSFNCOpenLayers1.OnPolyElementRightClick := TMSFNCOpenLayers1PolyElementRightClick;
  finally
    TMSFNCOpenLayers1.EndUpdate;
  end;
end;

Read the related guide

Handle OpenLayers right-click events

Wires OnMapRightClick, OnMarkerRightClick, and OnPolyElementRightClick to context actions.

Handle OpenLayers right-click eventsPascal
procedure TForm1.ConfigureOpenLayersContextEvents;
begin
  TMSFNCOpenLayers1.OnMapRightClick := TMSFNCOpenLayers1MapRightClick;
  TMSFNCOpenLayers1.OnMarkerRightClick := TMSFNCOpenLayers1MarkerRightClick;
  TMSFNCOpenLayers1.OnPolyElementRightClick := TMSFNCOpenLayers1PolyElementRightClick;
end;

procedure TForm1.TMSFNCOpenLayers1MapRightClick(Sender: TObject;
  AEventData: TTMSFNCMapsEventData);
begin
  { Show a map-level context menu at AEventData.Coordinate. }
end;

procedure TForm1.TMSFNCOpenLayers1MarkerRightClick(Sender: TObject;
  AEventData: TTMSFNCMapsEventData);
begin
  if Assigned(AEventData.Marker) then
    AEventData.Marker.Title := 'Selected marker';
end;

procedure TForm1.TMSFNCOpenLayers1PolyElementRightClick(Sender: TObject;
  AEventData: TTMSFNCMapsEventData);
begin
  if Assigned(AEventData.PolyElement) then
    AEventData.PolyElement.DataString := 'Selected poly element';
end;

Read the related guide