Skip to main content
Table of Contents

TTMSFNCMapBox Class

Displays interactive Mapbox maps with markers, shapes, routes, 3D styles, and browser-backed provider services.

API unit family: TMSFNCMapBox Inherits from: TTMSFNCCustomMapBox

Syntax

GeneratedPascalC++
TTMSFNCMapBox = class(TTMSFNCCustomMapBox)
class PASCALIMPLEMENTATION TTMSFNCMapBox : public TTMSFNCCustomMapBox

Properties

Name Description
Markers Contains the marker overlays displayed by the map. (inherited from TTMSFNCCustomMapBox)
Options Provides access to the provider-specific map options. (inherited from TTMSFNCCustomMapBox)

Methods

Name Description
AddBridge Adds a bridge object for browser communication.
AddMarker Adds a marker at the specified coordinate. (inherited from TTMSFNCCustomMapBox)
CanGoBack Returns whether browser history can navigate back.
CanGoForward Returns whether browser history can navigate forward.
CaptureScreenShot Captures a screenshot of the browser surface.
Clear Clears provider-specific map objects and resets the map state. (inherited from TTMSFNCCustomMapBox)
ClearCache Clears the browser cache.
DeInitialize Releases the browser and map surface.
EndUpdate Ends a batched update and refreshes provider-specific overlays. (inherited from TTMSFNCCustomMapBox)
ExecuteJavaScript Executes JavaScript in the browser surface.
ExecuteJavaScriptSync Executes JavaScript synchronously and returns its result.
GoBack Navigates back in browser history.
GoForward Navigates forward in browser history.
Initialize Initializes the browser and map surface.
IsFMXBrowser Returns whether the active browser is the framework browser.
LoadFile Loads a local file into the browser surface.
LoadHTML Loads HTML content into the browser surface.
NativeBrowser Returns the native browser pointer.
NativeDialog Returns the native dialog pointer.
NativeEnvironment Returns the native browser environment pointer.
Navigate Navigates to the configured map URL.
Reload Reloads the browser surface.
RemoveBridge Removes a browser communication bridge.
ShowDebugConsole Shows the browser debug console.
StopLoading Stops the current browser load operation.

Events

Name Description
OnMarkerDragEnd Occurs when a draggable marker has finished being moved. (inherited from TTMSFNCCustomMapBox)

Usage examples

Combine style, labels and marker editing

Combines API version, 3D MapBox options, labels, draggable markers and right-click events in one setup routine.

Combine style, labels and marker editingPascal
procedure TForm1.BuildMapBoxEditingScene;
var
  LMarker: TTMSFNCMapBoxMarker;
  LLabel: TTMSFNCMapsLabel;
begin
  TMSFNCMapBox1.BeginUpdate;
  try
    TMSFNCMapBox1.APIKey := '<your MapBox access token>';
    TMSFNCMapBox1.Options.Version := '3.24.0';
    TMSFNCMapBox1.Options.MapStyle := mbs3D;
    TMSFNCMapBox1.Options.TimeOfDay := todDay;
    TMSFNCMapBox1.Options.Tilt := 55;
    TMSFNCMapBox1.Options.Heading := 20;
    TMSFNCMapBox1.Options.DefaultLatitude := 40.7073;
    TMSFNCMapBox1.Options.DefaultLongitude := -74.0093;
    TMSFNCMapBox1.Options.DefaultZoomLevel := 15;

    LMarker := TMSFNCMapBox1.AddMarker(40.7073, -74.0093, 'Drag me');
    LMarker.Draggable := True;
    LMarker.ZIndex := 10;

    LLabel := TMSFNCMapBox1.Labels.Add;
    LLabel.Text := 'Editable MapBox stop';
    LLabel.Coordinate.Latitude := LMarker.Coordinate.Latitude;
    LLabel.Coordinate.Longitude := LMarker.Coordinate.Longitude;

    TMSFNCMapBox1.OnMarkerDragEnd := TMSFNCMapBox1MarkerDragEnd;
    TMSFNCMapBox1.OnMapRightClick := TMSFNCMapBox1MapRightClick;
  finally
    TMSFNCMapBox1.EndUpdate;
  end;
end;

Read the related guide

Handle MapBox right-click events

Wires OnMapRightClick, OnMarkerRightClick and OnPolyElementRightClick to context actions.

Handle MapBox right-click eventsPascal
procedure TForm1.ConfigureMapBoxContextEvents;
begin
  TMSFNCMapBox1.OnMapRightClick := TMSFNCMapBox1MapRightClick;
  TMSFNCMapBox1.OnMarkerRightClick := TMSFNCMapBox1MarkerRightClick;
  TMSFNCMapBox1.OnPolyElementRightClick := TMSFNCMapBox1PolyElementRightClick;
end;

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

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

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

Read the related guide