Back to Devexpress

TdxMapLayers Class

vcl-dxmaplayer-8297c77a.md

latest4.8 KB
Original Source

TdxMapLayers Class

A collection of map layers.

Declaration

delphi
TdxMapLayers = class(
    TcxComponentCollection
)

Remarks

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

Main API Members

The list below outlines key members of the TdxMapLayers class. These members allow you to access and manage individual map layers.

Collection Management API Members

AddCreates a new map layer of the required type and adds the layer to the collection.ClearClears the map layer collection.CountReturns the number of map layers in the collection.Items

Provides indexed access to map layers in the collection.

Map layer indexes in the 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.

RemoveRemoves an individual map layer from the collection.

General-Purpose API Members

AssignCopies map layers between collections.BeginUpdate | EndUpdateAllow you to avoid excessive redraw operations during batch collection changes.

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:

delphi
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;
cpp
#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
  }
}

Direct TdxMapLayers Class Reference

The TdxCustomMapControl.Layers property references a TdxMapLayers object.

Inheritance

TObject TPersistent TcxComponentCollection TdxMapLayers

See Also

TdxMapLayers Members

dxMapLayer Unit