ArcGIS Local Dynamic Map Service Layer

Download Samples Repository

Description

Demonstrates creating an ArcGISDynamicMapServiceLayer which references a LocalMapService.

"Desktop" Available for Desktop

Sample Code

<UserControl x:Class="ArcGISRuntime.Samples.Desktop.ArcGISDynamicMapServiceLayerLocalSample"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"             
             xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">
    <Grid>
		<esri:MapView x:Name="MyMapView"/>
	</Grid>
</UserControl>
using Esri.ArcGISRuntime.Layers;
using Esri.ArcGISRuntime.LocalServices;
using System;
using System.Windows;
using System.Windows.Controls;

namespace ArcGISRuntime.Samples.Desktop
{
    /// <summary>
    /// Demonstrates creating an ArcGISDynamicMapServiceLayer which references a LocalMapService.
    /// </summary>
    /// <title>ArcGIS Local Dynamic Map Service Layer</title>
	/// <category>Layers</category>
	/// <subcategory>Dynamic Service Layers</subcategory>
	/// <requiresLocalServer>true</requiresLocalServer>
	public partial class ArcGISDynamicMapServiceLayerLocalSample : UserControl
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ArcGISDynamicMapServiceLayerLocalSample"/> class.
        /// </summary>
        public ArcGISDynamicMapServiceLayerLocalSample()
        {
            InitializeComponent();
            CreateLocalServiceAndDynamicLayer();
        }

        public async void CreateLocalServiceAndDynamicLayer() 
        {
            try
            {
				LocalMapService localMapService = new LocalMapService(@"..\..\..\samples-data\maps\water-distribution-network.mpk");
                await localMapService.StartAsync();

                ArcGISDynamicMapServiceLayer arcGISDynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer() 
                {
                    ID = "arcGISDynamicMapServiceLayer",
                    ServiceUri = localMapService.UrlMapService,
                };

				MyMapView.Map.Layers.Add(arcGISDynamicMapServiceLayer);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}
Feedback on this topic?