public MainWindow() { // License setting and ArcGIS Runtime initialization is done in Application.xaml.cs. InitializeComponent(); var webMap = new ESRI.ArcGIS.Client.WebMap.Document(); webMap.GetMapCompleted += webMap_GetMapCompleted; // Get webmap from ArcGIS Online, this item is at this address, note the item Id in the Url: // http://www.arcgis.com/home/item.html?id=88b187a860934d8491bdff591d0b1e1a webMap.GetMapAsync("88b187a860934d8491bdff591d0b1e1a"); }
public MainWindow() { // License setting and ArcGIS Runtime initialization is done in Application.xaml.cs. InitializeComponent(); var webMap = new ESRI.ArcGIS.Client.WebMap.Document(); webMap.GetMapCompleted += webMap_GetMapCompleted; // Get webmap from ArcGIS Online, this item is at this address, note the item Id in the Url: // http://www.arcgis.com/home/item.html?id=88b187a860934d8491bdff591d0b1e1a webMap.GetMapAsync("88b187a860934d8491bdff591d0b1e1a"); }
private void TryLoadWebMap(string itemId) { try { // Create a new WebMap Document ESRI.ArcGIS.Client.WebMap.Document document = new ESRI.ArcGIS.Client.WebMap.Document(); // Handle the GetMapCompleted event. document.GetMapCompleted += (s, getMapCompletedEventArgs) => { // Check the Error property of the GetMapCompletedEventArgs for a connection or login failure. if (getMapCompletedEventArgs.Error != null) { // Show an error message box string message = getMapCompletedEventArgs.Error.Message + "\nWould you like to retry?"; MessageBoxResult result = MessageBox.Show(message, "Error Loading WebMap", MessageBoxButton.YesNo, MessageBoxImage.Error); if (result == MessageBoxResult.Yes) { TryLoadWebMap(itemId); } else { Application.Current.Shutdown(); } return; } // Webmap loaded sucessfully, insert the loaded map into the window and continue MapGrid.Children.Insert(0, getMapCompletedEventArgs.Map); _map = getMapCompletedEventArgs.Map; _webMap = getMapCompletedEventArgs.WebMap; _username = MainSignInDialog.UserName; MapLoaded(getMapCompletedEventArgs); }; // Call the GetMayAsync method to retrieve the WebMap by ArcGIS.com item identifier. document.GetMapAsync(itemId, null); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } }
private void TryLoadWebMap(string itemId) { try { // Create a new WebMap Document ESRI.ArcGIS.Client.WebMap.Document document = new ESRI.ArcGIS.Client.WebMap.Document(); // Handle the GetMapCompleted event. document.GetMapCompleted += (s, getMapCompletedEventArgs) => { // Check the Error property of the GetMapCompletedEventArgs for a connection or login failure. if (getMapCompletedEventArgs.Error != null) { // Show an error message box string message = getMapCompletedEventArgs.Error.Message + "\nWould you like to retry?"; MessageBoxResult result = MessageBox.Show(message, "Error Loading WebMap", MessageBoxButton.YesNo, MessageBoxImage.Error); if (result == MessageBoxResult.Yes) TryLoadWebMap(itemId); else Application.Current.Shutdown(); return; } // Webmap loaded sucessfully, insert the loaded map into the window and continue MapGrid.Children.Insert(0, getMapCompletedEventArgs.Map); _map = getMapCompletedEventArgs.Map; _webMap = getMapCompletedEventArgs.WebMap; _username = MainSignInDialog.UserName; MapLoaded(getMapCompletedEventArgs); }; // Call the GetMayAsync method to retrieve the WebMap by ArcGIS.com item identifier. document.GetMapAsync(itemId, null); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } }