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.v21.2.dll

NuGet Packages: DevExpress.Win.Design, DevExpress.Win.Map

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 CapabilitiesRespondedEventArgs.Layers collection.

View Example

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, CapabilitiesRespondedEventArgs 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);
        }
    }
}
See Also