ArcGIS Runtime SDK for .NET Samples

WMS layer (URL)

WMS layer


// Copyright 2017 Esri.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
// language governing permissions and limitations under the License.

using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.UI.Controls;
using Foundation;
using System;
using System.Collections.Generic;
using UIKit;

namespace ArcGISRuntime.Samples.WMSLayerUrl
        "WMS layer (URL)",
        "This sample demonstrates how to add a layer from a WMS service to a map.",
    public class WMSLayerUrl : UIViewController
        // Create and hold reference to the used MapView
        private MapView _myMapView = new MapView();

        // Hold the URL to the WMS service showing the geology of Africa
        private Uri wmsUrl = new Uri("");

        // Hold a list of uniquely-identifying WMS layer names to display
        private List<String> wmsLayerNames = new List<string> { "0" };

        public WMSLayerUrl()
            Title = "WMS layer (URL)";

        public override void ViewDidLoad()

            // Create the UI, setup the control references

            // Initialize the map

        private void CreateLayout()
            // Add the mapview to the view

        private void Initialize()
            // Apply an imagery basemap to the map
            Map myMap = new Map(Basemap.CreateImagery());

            // Set the initial viewpoint
            myMap.InitialViewpoint = new Viewpoint(
                new MapPoint(25.450, -4.59, new SpatialReference(4326)), 1000000);

            // Add the map to the mapview
            _myMapView.Map = myMap;

            // Create a new WMS layer displaying the specified layers from the service
            WmsLayer myWmsLayer = new WmsLayer(wmsUrl, wmsLayerNames);

            // Add the layer to the map

        public override void ViewDidLayoutSubviews()
            // Setup the visual frame for the MapView
            _myMapView.Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height);


In this topic
  1. Code