Skip to main content
All docs
V19.2

CapabilitiesResponsedEventArgs.Layers Property

Returns a collection of available layers supported by a Web Map Service.

Namespace: DevExpress.XtraMap

Assembly: DevExpress.XtraMap.v19.2.dll

Declaration

public WmsLayerCollection Layers { get; }

Property Value

Type Description
WmsLayerCollection

A collection of WmsLayer objects.

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.

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);
        }
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Layers 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.

See Also