vcl-dxmapcontrol-dot-tdxcustommapcontrol.md
Provides access to the map layer collection.
property Layers: TdxMapLayers read; write;
| Type | Description |
|---|---|
| TdxMapLayers |
A collection of map layers.
|
Map Control content is arranged into layers that can display different information, such as terrain, roads, routes, waypoints, etc.
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.
Map layer indexes in the Layers collection also determine the Z-order (draw order) of corresponding layers. A map layer with the highest index is displayed on top of all other layers.
Tip
The more transparent elements a map layer has, the higher collection index (Z-order) it should have. Otherwise, an opaque layer overlaps all transparent layers beneath it.
For example, we recommend that you display a map item layer with shapes and other markers on top of all other layers.
You can use the Collection Editor dialog to manage map layers at design time. To open the dialog, do any of the following:
Layers property in the Object Inspector.Click Add New , Delete Selected , Move Selected Up , and Move Selected Down buttons to manage map layers.
The Add New button creates a tile map layer. To create other supported map layers, open the button’s drop-down menu:
You can call the following functions to create corresponding map layers (as an alternative to the Layers.Add function):
AddImageTileLayerCreates a new image tile layer and adds it to the map layer collection.AddItemFileLayerCreates a new item file layer and adds it to the map layer collection.AddItemLayerCreates a new item layer.
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; // 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;
#include "dxAzureMapImageryDataProvider.hpp" // Declares TdxMapControlAzureMapImageryDataProvider
// ...
void __fastcall TMyForm::AddAzureMapLayer(const UnicodeString &AAzureKey)
{
TdxMapLayer *ALayer;
TdxMapImageTileLayer *ATileLayer;
TdxMapControlAzureMapImageryDataProvider *AProvider;
ALayer = dxMapControl1->Layers->Add(__classid(TdxMapImageTileLayer));
ATileLayer = dynamic_cast<TdxMapImageTileLayer*>(ALayer);
ATileLayer->ProviderClass = __classid(TdxMapControlAzureMapImageryDataProvider);
AProvider = dynamic_cast<TdxMapControlAzureMapImageryDataProvider*>(ATileLayer->Provider);
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
}
}
See Also