WmsDataProvider.ActiveLayerName Property
Gets or sets the active layer name retrieved from a Web Map Service.
Namespace: DevExpress.XtraMap
Assembly: DevExpress.XtraMap.v19.2.dll
Declaration
Property Value
Type | Default | Description |
---|---|---|
String | String.Empty | A String value specifying the layer name. |
Example
This example demonstrates how to obtain a collection of layers supported by the Web Map Service.
To do this, use the WmsDataProvider.ResponseCapabilities event arguments to obtain the CapabilitiesResponsedEventArgs.Layers collection.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-obtain-a-collection-of-available-wms-layers-in-the-rensponsecapabilities-event-hand-t359209
using DevExpress.XtraMap;
using DevExpress.XtraTreeList;
using System;
using System.Linq;
using System.Windows.Forms;
namespace WmsDataProviderExample {
public partial class Form1 : Form {
ImageLayer WmsLayer { get { return mapControl.Layers["WmsLayer"] as ImageLayer; } }
WmsDataProvider Provider { get { return WmsLayer.DataProvider as WmsDataProvider; } }
public Form1() {
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) {
// Specify a server URI.
Provider.ServerUri = "http://INSERT_YOUR_SERVER_URI";
// Handle the ResponseCapabilities event.
Provider.ResponseCapabilities += OnResponseCapabalities;
}
void OnResponseCapabalities(object sender, CapabilitiesResponsedEventArgs e) {
tlLayers.DataSource = e.Layers;
}
private void OnGetCellValue(object sender, VirtualTreeGetCellValueInfo e) {
WmsLayer layer = e.Node as WmsLayer;
if (layer == null) return;
if (e.Column.FieldName == "LayerName") {
e.CellData = layer.Title;
}
}
private void OnGetChildNodes(object sender, VirtualTreeGetChildNodesInfo e) {
WmsLayerCollection layers = e.Node as WmsLayerCollection;
if (layers != null) {
e.Children = layers.ToList();
}
WmsLayer layer = e.Node as WmsLayer;
if (layer != null) {
e.Children = layer.Children.ToList();
}
}
private void OnFocusedNodeChanged(object sender, FocusedNodeChangedEventArgs e) {
WmsLayer layer = tlLayers.GetDataRecordByNode(e.Node) as WmsLayer;
if (layer == null) return;
Provider.ActiveLayerName = layer.Name;
mapControl.ZoomToRegion(layer.LeftTop, layer.RightBottom, 0.15);
}
}
}
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the ActiveLayerName property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.