Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TdxCustomMapControl.Layers Property

Provides access to the map layer collection.

#Declaration

Delphi
property Layers: TdxMapLayers read; write;

#Property Value

Type Description
TdxMapLayers

A collection of map layers.

#Remarks

Map Control content is arranged into layers that can display different information, such as terrain, roads, routes, waypoints, etc.

VCL Map Control: An Azure Maps Usage Example

#Available API Functionality

Call Layers.Add, Layers.Clear, and Layers.Remove methods to manage layers in the Map Control. The Layers.Items property provides indexed access to all layers in the collection.

Refer to the TdxMapLayers class description for detailed information on all available options.

#Design-Time Layer Management

You can use the Collection Editor dialog to manage map layers at design time. To open the dialog, do any of the following:

  • Select the Map Control, and click the ellipsis button to the right of the Layers property in the Object Inspector.
  • Double-click the Map Control.
  • Click Layers Editor… in the control’s context menu.

#Collection Editor

Click Add New, Delete Selected, Move Selected Up, and Move Selected Down buttons to manage map layers.

VCL Map Control: The Map Layer Collection Editor

The Add New button creates a tile map layer. To create other supported map layers, open the button’s drop-down menu:

VCL Map Control: Other Map Layer Creation Options

#Type-Specific Layer Creation Functions

You can call the following functions to create corresponding map layers (as an alternative to the Layers.Add function):

AddImageTileLayer
Creates a new image tile layer and adds it to the map layer collection.
AddItemFileLayer
Creates a new item file layer and adds it to the map layer collection.
AddItemLayer
Creates a new item layer.

#Code Example: Add a Tile Map Layer and Load Azure Maps Data

The following code example implements a procedure that accepts an Azure Maps account key, creates and configures a map tile layer, and loads data:

uses
  dxAzureMapImageryDataProvider;  // This unit declares TdxMapControlAzureMapImageryDataProvider
// ...

procedure TMyForm.AddAzureMapLayer(const AAzureKey: string);
var
  ATileLayer: TdxMapImageTileLayer;
  AProvider: TdxMapControlAzureMapImageryDataProvider;
begin
  ATileLayer := dxMapControl1.Layers.Add(TdxMapImageTileLayer) as TdxMapImageTileLayer;
  ATileLayer.ProviderClass := TdxMapControlAzureMapImageryDataProvider;
  AProvider := ATileLayer.Provider as TdxMapControlAzureMapImageryDataProvider;
  AProvider.BeginUpdate;  // Initiates the following batch change
  try
    AProvider.AzureKey := AAzureKey;  // Assigns the Azure account key
    AProvider.Tileset := TdxAzureMapTileset.Satellite;  // Changes the default tileset
    AProvider.MaxParallelConnectionCount := 8;  // Explicitly defines the number of parallel connections
  finally
    AProvider.EndUpdate;  // Calls EndUpdate regardless of the batch operation's success
  end;
end;
See Also