This sample demonstrates adding data in a WebMap document housed via ArcGIS Online (http://www.arcgis.com) in a WPF application. The WebMap.GetMapAsync Method call takes a Globally Unique Identifier (GUID) for the WebMap service provided by ArcGIS Online to obtain the geographic data layers. The WebMap's GetMapCompletedEventArgs.Map Property is used to add a Map Class to the WPF application for visual display. The map loaded in this sample includes an Open Geospatial Consortium (OGC) WMS layer. The sample also uses the ProxyUrl Property to demonstrate how a proxy service brokers web requests between the WPF client and the ArcGIS Online service that exposes a WebMap document. Use a proxy service when the WebMap document is not hosted on a site that provides a cross domain policy file (clientaccesspolicy.xml or crossdomain.xml).
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ESRI.ArcGIS.Client.WebMap;
namespace ArcGISWPFSDK
{
publicpartialclass WebMapWithWMS : UserControl
{
public WebMapWithWMS()
{
InitializeComponent();
Document webMap = new Document();
webMap.GetMapCompleted += webMap_GetMapCompleted;
webMap.ProxyUrl = "http://servicesbeta3.esri.com/SilverlightDemos/ProxyPage/proxy.ashx";
webMap.GetMapAsync("b3e11e1d7aac4d6a98fde6b864d3a2b7");
}
void webMap_GetMapCompleted(object sender, GetMapCompletedEventArgs e)
{
if (e.Error == null)
LayoutRoot.Children.Add(e.Map);
}
}
}
Imports System.Windows.Controls
Imports ESRI.ArcGIS.Client.WebMap
Namespace ArcGISWPFSDK
PartialPublicClass WebMapWithWMS
Inherits UserControl
PublicSubNew()
InitializeComponent()
Dim webMap AsNew Document()
AddHandler webMap.GetMapCompleted, AddressOf webMap_GetMapCompleted
webMap.ProxyUrl = "http://servicesbeta3.esri.com/SilverlightDemos/ProxyPage/proxy.ashx"
webMap.GetMapAsync("b3e11e1d7aac4d6a98fde6b864d3a2b7")
EndSubPrivateSub webMap_GetMapCompleted(ByVal sender AsObject, ByVal e As GetMapCompletedEventArgs)
If e.ErrorIsNothingThen
LayoutRoot.Children.Add(e.Map)
EndIfEndSubEndClassEndNamespace