Skip to main content
A newer version of this page is available. .

WmsDataProvider.ServerUri Property

Gets or sets the server URI, which supports a Web Map Service.

Namespace: DevExpress.XtraMap

Assembly: DevExpress.XtraMap.v18.2.dll

Declaration

[DefaultValue("")]
public string ServerUri { get; set; }

Property Value

Type Default Description
String String.Empty

A String value.

Remarks

The Map control takes into account the base URI in the ServerUri string, therefore the values after the ? sign in the query string are not considered. Use the WmsDataProvider.CustomParameters collection to pass additional parameters with the request to the server.

Note that the Map control automatically specifies and passes the service and version parameter values.

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 snippets (auto-collected from DevExpress Examples) contain references to the ServerUri 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