private async void StartGeodatabaseGeneration() { // Update the geodatabase path _gdbPath = GetGdbPath(); // Create a task for generating a geodatabase (GeodatabaseSyncTask) _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri); // Get the current extent of the red preview box Envelope extent = MyMapView.GraphicsOverlays.First().Graphics.First().Geometry as Envelope; // Get the default parameters for the generate geodatabase task GenerateGeodatabaseParameters generateParams = await _gdbSyncTask.CreateDefaultGenerateGeodatabaseParametersAsync(extent); // Create a generate geodatabase job _generateGdbJob = _gdbSyncTask.GenerateGeodatabase(generateParams, _gdbPath); // Handle the job changed event _generateGdbJob.JobChanged += GenerateGdbJobChanged; // Handle the progress changed event (to show progress bar) _generateGdbJob.ProgressChanged += ((sender, e) => { UpdateProgressBar(); }); // Start the job _generateGdbJob.Start(); }
private async void Initialize() { // Create a tile cache and load it with the SanFrancisco streets tpk. TileCache tileCache = new TileCache(DataManager.GetDataFolder("3f1bbf0ec70b409a975f5c91f363fe7d", "SanFrancisco.tpk")); // Create the corresponding layer based on the tile cache. ArcGISTiledLayer tileLayer = new ArcGISTiledLayer(tileCache); // Create the basemap based on the tile cache. Basemap sfBasemap = new Basemap(tileLayer); // Create the map with the tile-based basemap. Map myMap = new Map(sfBasemap); // Assign the map to the MapView. MyMapView.Map = myMap; // Create a new symbol for the extent graphic. SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Red, 2); // Create graphics overlay for the extent graphic and apply a renderer. GraphicsOverlay extentOverlay = new GraphicsOverlay { Renderer = new SimpleRenderer(lineSymbol) }; // Add graphics overlay to the map view. MyMapView.GraphicsOverlays.Add(extentOverlay); // Set up an event handler for when the viewpoint (extent) changes. MyMapView.ViewpointChanged += MapViewExtentChanged; // Create a task for generating a geodatabase (GeodatabaseSyncTask). _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri); // Add all layers from the service to the map. foreach (IdInfo layer in _gdbSyncTask.ServiceInfo.LayerInfos) { // Get the URL for this particular layer. Uri onlineTableUri = new Uri(_featureServiceUri + "/" + layer.Id); // Create the ServiceFeatureTable. ServiceFeatureTable onlineTable = new ServiceFeatureTable(onlineTableUri); // Wait for the table to load. await onlineTable.LoadAsync(); // Add the layer to the map's operational layers if load succeeds. if (onlineTable.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded) { myMap.OperationalLayers.Add(new FeatureLayer(onlineTable)); } } // Update the extent graphic so that it is valid before user interaction. UpdateMapExtent(); // Enable the generate button now that the sample is ready. MyGenerateButton.IsEnabled = true; }
private async void StartGeodatabaseGeneration() { // Create a task for generating a geodatabase (GeodatabaseSyncTask) _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri); // Get the (only) graphic in the map view GraphicsOverlay redPreviewBox = myMapView.GraphicsOverlays.FirstOrDefault(); // Get the current extent of the red preview box Envelope extent = redPreviewBox.Extent as Envelope; // Get the default parameters for the generate geodatabase task GenerateGeodatabaseParameters generateParams = await _gdbSyncTask.CreateDefaultGenerateGeodatabaseParametersAsync(extent); // Create a generate geodatabase job GenerateGeodatabaseJob generateGdbJob = _gdbSyncTask.GenerateGeodatabase(generateParams, _gdbPath); // Handle the job changed event generateGdbJob.JobChanged += GenerateGdbJobChanged; // Handle the progress changed event with an inline (lambda) function to show the progress bar generateGdbJob.ProgressChanged += ((object sender, EventArgs e) => { // Get the job GenerateGeodatabaseJob job = sender as GenerateGeodatabaseJob; // Update the progress bar UpdateProgressBar(job.Progress); }); // Start the job generateGdbJob.Start(); }
private async void StartGeodatabaseGeneration() { // 同期させたいレイヤーで ジオデータベースタスク オブジェクトを作成する (GeodatabaseSyncTask) _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(FEATURELAYER_SERVICE_URL); // ジオデータベース作成のためのパラメータを取得する Envelope extent = myMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry).TargetGeometry as Envelope; // ジオデータベース作成 タスクオブジェクトのデフォルトパラメータを取得する GenerateGeodatabaseParameters generateParams = await _gdbSyncTask.CreateDefaultGenerateGeodatabaseParametersAsync(extent); // ジオデータベースの作成ジョブオブジェクトを作成する GenerateGeodatabaseJob generateGdbJob = _gdbSyncTask.GenerateGeodatabase(generateParams, _gdbPath); // ジョブ変更イベントを処理する generateGdbJob.JobChanged += GenerateGdbJobChanged; //進行状況を変更したイベントをインライン(ラムダ)関数で処理してプログレスバーを表示する generateGdbJob.ProgressChanged += ((object sender, EventArgs e) => { // ジョブを取得 GenerateGeodatabaseJob job = sender as GenerateGeodatabaseJob; // プログレスバーの更新 UpdateProgressBar(job.Progress); }); // ジオデータベース作成のジョブをスタートする generateGdbJob.Start(); }
private async Task StartGeodatabaseGeneration() { // Create a task for generating a geodatabase (GeodatabaseSyncTask). _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri); // Get the current extent of the red preview box. Envelope extent = MyMapView.GraphicsOverlays.First().Graphics.First().Geometry as Envelope; // Get the default parameters for the generate geodatabase task. GenerateGeodatabaseParameters generateParams = await _gdbSyncTask.CreateDefaultGenerateGeodatabaseParametersAsync(extent); // Create a generate geodatabase job. _generateGdbJob = _gdbSyncTask.GenerateGeodatabase(generateParams, _gdbPath); // Handle the progress changed event (to show progress bar). _generateGdbJob.ProgressChanged += (sender, e) => { UpdateProgressBar(); }; // Show the progress bar. MyProgressBar.Visibility = Visibility.Visible; // Start the job. _generateGdbJob.Start(); // Get the result. Geodatabase resultGdb = await _generateGdbJob.GetResultAsync(); // Hide the progress bar. MyProgressBar.Visibility = Visibility.Hidden; // Do the rest of the work. await HandleGenerationCompleted(resultGdb); }
private async Task StartGeodatabaseGeneration() { // Update geodatabase path. _gdbPath = $"{Path.GetTempFileName()}.geodatabase"; // Create a task for generating a geodatabase (GeodatabaseSyncTask). _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri); // Get the current extent of the red preview box. Envelope extent = _myMapView.GraphicsOverlays.First().Graphics.First().Geometry as Envelope; // Get the default parameters for the generate geodatabase task. GenerateGeodatabaseParameters generateParams = await _gdbSyncTask.CreateDefaultGenerateGeodatabaseParametersAsync(extent); // Create a generate geodatabase job. _generateGdbJob = _gdbSyncTask.GenerateGeodatabase(generateParams, _gdbPath); // Handle the progress changed event (to show progress bar). _generateGdbJob.ProgressChanged += GenerateGdbJob_ProgressChanged; // Start the job. _generateGdbJob.Start(); // Get the result. Geodatabase resultGdb = await _generateGdbJob.GetResultAsync(); // Do the rest of the work. await HandleGenerationStatusChange(_generateGdbJob, resultGdb); }
private async void Initialize() { // Create a tile cache and load it with the SanFrancisco streets tpk TileCache tileCache = new TileCache(GetTpkPath()); // Create the corresponding layer based on the tile cache ArcGISTiledLayer tileLayer = new ArcGISTiledLayer(tileCache); // Create the basemap based on the tile cache Basemap sfBasemap = new Basemap(tileLayer); // Create the map with the tile-based basemap Map myMap = new Map(sfBasemap); // Assign the map to the MapView myMapView.Map = myMap; // Create a new symbol for the extent graphic SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Red, 2); // Create graphics overlay for the extent graphic and apply a renderer GraphicsOverlay extentOverlay = new GraphicsOverlay(); extentOverlay.Renderer = new SimpleRenderer(lineSymbol); // Add graphics overlay to the map view myMapView.GraphicsOverlays.Add(extentOverlay); // Set up an event handler for when the viewpoint (extent) changes myMapView.ViewpointChanged += MapViewExtentChanged; // Set up event handler for mapview taps myMapView.GeoViewTapped += GeoViewTapped; // Update the local data path for the geodatabase file _gdbPath = GetFileStreamPath("wildfire.geodatabase").AbsolutePath; // Create a task for generating a geodatabase (GeodatabaseSyncTask) _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri); // Add all graphics from the service to the map foreach (IdInfo layer in _gdbSyncTask.ServiceInfo.LayerInfos) { // Get the Uri for this particular layer Uri onlineTableUri = new Uri(_featureServiceUri + "/" + layer.Id); // Create the ServiceFeatureTable ServiceFeatureTable onlineTable = new ServiceFeatureTable(onlineTableUri); // Wait for the table to load await onlineTable.LoadAsync(); // Add the layer to the map's operational layers if load succeeds if (onlineTable.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded) { myMap.OperationalLayers.Add(new FeatureLayer(onlineTable)); } } }
private async Task UnregisterAndRemoveMobileMapPackage(MobileMapPackage mobileMapPackage) { // Unregister all geodatabases from all maps that are part of the mobile map package. // Offline areas that are downloaded by using OfflineMapTask will contain a single // map in them but it is a good practice to handle the case of multiple maps. foreach (Map map in mobileMapPackage.Maps) { // Find all geodatabases from the used map. List <Geodatabase> geodatabasesToUnregister = new List <Geodatabase>(); // Add all geodatabases used in the feature layers. foreach (FeatureLayer featureLayer in map.OperationalLayers.OfType <FeatureLayer>()) { GeodatabaseFeatureTable geodatabaseFeatureTable = featureLayer.FeatureTable as GeodatabaseFeatureTable; if (geodatabaseFeatureTable == null) { continue; } // Add the geodatabase feature table if it isn't already in the list. if (geodatabasesToUnregister.All(x => x.Path != geodatabaseFeatureTable.Geodatabase.Path)) { geodatabasesToUnregister.Add(geodatabaseFeatureTable.Geodatabase); } } // Add all geodatabases used in a table. foreach (FeatureTable featureTable in map.Tables) { GeodatabaseFeatureTable geodatabaseFeatureTable = featureTable as GeodatabaseFeatureTable; if (geodatabaseFeatureTable == null) { continue; } // Add the geodatabase feature table if it isn't already in the list. if (geodatabasesToUnregister.All(x => x.Path != geodatabaseFeatureTable.Geodatabase.Path)) { geodatabasesToUnregister.Add(geodatabaseFeatureTable.Geodatabase); } } // Unregister geodatabases that were used. foreach (Geodatabase geodatabaseToUnregister in geodatabasesToUnregister) { GeodatabaseSyncTask geodatabaSyncTask = await GeodatabaseSyncTask.CreateAsync(geodatabaseToUnregister.Source); await geodatabaSyncTask.UnregisterGeodatabaseAsync(geodatabaseToUnregister); } // Make sure that all geodatabases are closed and locks released. foreach (Geodatabase geodatabase in geodatabasesToUnregister) { geodatabase.Close(); } } // Remove package. Directory.Delete(mobileMapPackage.Path, true); }
private async void Initialize() { // Create a tile cache and load it with the SanFrancisco streets tpk TileCache _tileCache = new TileCache(GetTpkPath()); // Create the corresponding layer based on the tile cache ArcGISTiledLayer _tileLayer = new ArcGISTiledLayer(_tileCache); // Create the basemap based on the tile cache Basemap _sfBasemap = new Basemap(_tileLayer); // Create the map with the tile-based basemap Map myMap = new Map(_sfBasemap); // Assign the map to the MapView MyMapView.Map = myMap; // Create a new symbol for the extent graphic SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Colors.Red, 2); // Create graphics overlay for the extent graphic and apply a renderer GraphicsOverlay extentOverlay = new GraphicsOverlay(); extentOverlay.Renderer = new SimpleRenderer(lineSymbol); // Add graphics overlay to the map view MyMapView.GraphicsOverlays.Add(extentOverlay); // Set up an event handler for when the viewpoint (extent) changes MyMapView.ViewpointChanged += MapViewExtentChanged; // Create a task for generating a geodatabase (GeodatabaseSyncTask) _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri); // Add all graphics from the service to the map foreach (var layer in _gdbSyncTask.ServiceInfo.LayerInfos) { // Create the ServiceFeatureTable for this particular layer ServiceFeatureTable onlineTable = new ServiceFeatureTable(new Uri(_featureServiceUri + "/" + layer.Id)); // Wait for the table to load await onlineTable.LoadAsync(); // Add the layer to the map's operational layers if load succeeds if (onlineTable.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded) { myMap.OperationalLayers.Add(new FeatureLayer(onlineTable)); } } // Update the extent graphic so that it is valid before user interaction UpdateMapExtent(); // Enable the generate button now that the sample is ready MyGenerateButton.IsEnabled = true; }
/** * GeoDatabaseを新規に作成する * ① 同期させたいArcGIS Online の Feature Layer でタスクを作成する ****/ private async void createGeodatabaseSyncTask() { // TODO 同期させたいレイヤーで geodatabase 作成 タスクオブジェクトを作成する var featureServiceUri = new Uri(FEATURELAYER_SERVICE_URL); geodatabaseSyncTask = await GeodatabaseSyncTask.CreateAsync(featureServiceUri); // ② 同期させたいArcGIS Online の Feature Layer のパラメータを取得する generateGeodatabaseParameters(); }
// Synchronize edits in the local geodatabase with the service. private async void SynchronizeEdits(object sender, EventArgs e) { // Show the progress bar while the sync is working. _progressBar.Hidden = false; try { // Create a sync task with the URL of the feature service to sync. GeodatabaseSyncTask syncTask = await GeodatabaseSyncTask.CreateAsync(new Uri(SyncServiceUrl)); // Create sync parameters. SyncGeodatabaseParameters taskParameters = await syncTask.CreateDefaultSyncGeodatabaseParametersAsync(_localGeodatabase); // Create a synchronize geodatabase job, pass in the parameters and the geodatabase. SyncGeodatabaseJob job = syncTask.SyncGeodatabase(taskParameters, _localGeodatabase); // Handle the JobChanged event for the job. job.JobChanged += (s, arg) => { InvokeOnMainThread(() => { // Update the progress bar. UpdateProgressBar(job.Progress); switch (job.Status) { // Report changes in the job status. case JobStatus.Succeeded: _statusLabel.Text = "Synchronization is complete!"; _progressBar.Hidden = true; break; case JobStatus.Failed: // Report failure. _statusLabel.Text = job.Error.Message; _progressBar.Hidden = true; break; default: _statusLabel.Text = "Sync in progress ..."; break; } }); }; // Await the completion of the job. await job.GetResultAsync(); } catch (Exception ex) { // Show the message if an exception occurred. _statusLabel.Text = "Error when synchronizing: " + ex.Message; } }
// Synchronize edits in the local geodatabase with the service public async void SynchronizeEdits(object sender, EventArgs e) { // Show the progress bar while the sync is working _progressBar.Visibility = Android.Views.ViewStates.Visible; try { // Create a sync task with the URL of the feature service to sync GeodatabaseSyncTask syncTask = await GeodatabaseSyncTask.CreateAsync(new Uri(SyncServiceUrl)); // Create sync parameters SyncGeodatabaseParameters taskParameters = await syncTask.CreateDefaultSyncGeodatabaseParametersAsync(_localGeodatabase); // Create a synchronize geodatabase job, pass in the parameters and the geodatabase SyncGeodatabaseJob job = syncTask.SyncGeodatabase(taskParameters, _localGeodatabase); // Handle the JobChanged event for the job job.JobChanged += (s, arg) => { RunOnUiThread(() => { // Update the progress bar UpdateProgressBar(job.Progress); // Report changes in the job status if (job.Status == JobStatus.Succeeded) { _messageTextBlock.Text = "Synchronization is complete!"; _progressBar.Visibility = Android.Views.ViewStates.Gone; } else if (job.Status == JobStatus.Failed) { // Report failure ... _messageTextBlock.Text = job.Error.Message; _progressBar.Visibility = Android.Views.ViewStates.Gone; } else { // Report that the job is in progress ... _messageTextBlock.Text = "Sync in progress ..."; } }); }; // Await the completion of the job await job.GetResultAsync(); } catch (Exception ex) { // Show the message if an exception occurred _messageTextBlock.Text = "Error when synchronizing: " + ex.Message; } }
//////////////////////////////////////////////////////////////// // 同期 //////////////////////////////////////////////////////////////// /** * サーバー(AGOL)と同期する * ① 同期タスクを作成する * ② 同期パラメータを取得する **/ private async void OnSyncClick(object sender, RoutedEventArgs e) { // 同期したいレイヤーでタスクオブジェクトを作成する geodatabaseSyncTask = await GeodatabaseSyncTask.CreateAsync(new Uri(FEATURELAYER_SERVICE_URL)); readGeoDatabase(); // タスクオブジェクトから同期するためのパラメータを作成する syncParams = await geodatabaseSyncTask.CreateDefaultSyncGeodatabaseParametersAsync(geodatabase); // パラーメータを使用してgeodatabaseを同期する syncGeodatabase(); }
// Synchronize edits in the local geodatabase with the service public async void SynchronizeEdits(object sender, EventArgs e) { // Show the progress bar while the sync is working LoadingProgressBar.IsVisible = true; try { // Create a sync task with the URL of the feature service to sync GeodatabaseSyncTask syncTask = await GeodatabaseSyncTask.CreateAsync(new Uri(SyncServiceUrl)); // Create sync parameters SyncGeodatabaseParameters taskParameters = await syncTask.CreateDefaultSyncGeodatabaseParametersAsync(_localGeodatabase); // Create a synchronize geodatabase job, pass in the parameters and the geodatabase SyncGeodatabaseJob job = syncTask.SyncGeodatabase(taskParameters, _localGeodatabase); // Handle the JobChanged event for the job job.JobChanged += (s, arg) => { // Report changes in the job status if (job.Status == JobStatus.Succeeded) { // Report success ... Device.BeginInvokeOnMainThread(() => MessageTextBlock.Text = "Synchronization is complete!"); } else if (job.Status == JobStatus.Failed) { // Report failure ... Device.BeginInvokeOnMainThread(() => MessageTextBlock.Text = job.Error.Message); } else { // Report that the job is in progress ... Device.BeginInvokeOnMainThread(() => MessageTextBlock.Text = "Sync in progress ..."); } }; // Await the completion of the job await job.GetResultAsync(); } catch (Exception ex) { // Show the message if an exception occurred MessageTextBlock.Text = "Error when synchronizing: " + ex.Message; } finally { // Hide the progress bar when the sync job is complete LoadingProgressBar.IsVisible = false; } }
// Synchronize edits in the local geodatabase with the service public async void SynchronizeEdits(object sender, RoutedEventArgs e) { // Show the progress bar while the sync is working LoadingProgressBar.Visibility = Visibility.Visible; try { // Create a sync task with the URL of the feature service to sync var syncTask = await GeodatabaseSyncTask.CreateAsync(new Uri(SyncServiceUrl)); // Create sync parameters var taskParameters = await syncTask.CreateDefaultSyncGeodatabaseParametersAsync(_localGeodatabase); // Create a synchronize geodatabase job, pass in the parameters and the geodatabase SyncGeodatabaseJob job = syncTask.SyncGeodatabase(taskParameters, _localGeodatabase); // Handle the JobChanged event for the job job.JobChanged += async(s, arg) => { // Report changes in the job status if (job.Status == JobStatus.Succeeded) { // Report success ... await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => MessageTextBlock.Text = "Synchronization is complete!"); } else if (job.Status == JobStatus.Failed) { // Report failure ... await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => MessageTextBlock.Text = job.Error.Message); } else { // Report that the job is in progress ... await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => MessageTextBlock.Text = "Sync in progress ..."); } }; // Await the completion of the job var result = await job.GetResultAsync(); } catch (Exception ex) { // Show the message if an exception occurred MessageTextBlock.Text = "Error when synchronizing: " + ex.Message; } finally { // Hide the progress bar when the sync job is complete LoadingProgressBar.Visibility = Visibility.Collapsed; } }
private async void Initialize() { // タイル キャッシュをを読み込む TileCache tileCache = new TileCache(GetTpkPath()); // タイル キャッシュレイヤーの作成 ArcGISTiledLayer tileLayer = new ArcGISTiledLayer(tileCache); // ベースマップクラスにタイル キャッシュ レイヤーを設定 Basemap sfBasemap = new Basemap(tileLayer); // マップにタイル キャッシュ レイヤーのベースマップを設定 Map myMap = new Map(sfBasemap); Envelope initialLocation = new Envelope( 15539982.3500528, 4255968.158699, 15545870.466201, 4262306.70411199, SpatialReferences.WebMercator); myMap.InitialViewpoint = new Viewpoint(initialLocation); // MapView に作成したマップを設定 myMapView.Map = myMap; // ジオデータベース ファイルのローカルデータパスを取得 _gdbPath = GetGdbPath(); // ジオデータベースを生成するためのタスクを作成する _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(FEATURELAYER_SERVICE_URL); // サービスから地図にフィーチャ レイヤーを追加する foreach (IdInfo layer in _gdbSyncTask.ServiceInfo.LayerInfos) { Uri onlineTableUri = new Uri(FEATURELAYER_SERVICE_URL + "/" + layer.Id); // ServiceFeatureTableを作成する ServiceFeatureTable onlineTable = new ServiceFeatureTable(onlineTableUri); await onlineTable.LoadAsync(); // ロードが成功した場合は、マップの操作レイヤーにレイヤーを追加 if (onlineTable.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded) { myMap.OperationalLayers.Add(new FeatureLayer(onlineTable)); } } }
private async Task StartGeodatabaseGeneration() { // Update the geodatabase path. _gdbPath = $"{Path.GetTempFileName()}.geodatabase"; // Create a task for generating a geodatabase (GeodatabaseSyncTask). _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri); // Get the (only) graphic in the map view. Graphic redPreviewBox = myMapView.GraphicsOverlays.First().Graphics.First(); // Get the current extent of the red preview box. Envelope extent = redPreviewBox.Geometry as Envelope; // Get the default parameters for the generate geodatabase task. GenerateGeodatabaseParameters generateParams = await _gdbSyncTask.CreateDefaultGenerateGeodatabaseParametersAsync(extent); // Create a generate geodatabase job. GenerateGeodatabaseJob generateGdbJob = _gdbSyncTask.GenerateGeodatabase(generateParams, _gdbPath); // Show the progress bar. myProgressBar.IsVisible = true; // Handle the progress changed event with an inline (lambda) function to show the progress bar. generateGdbJob.ProgressChanged += (sender, e) => { // Get the job. GenerateGeodatabaseJob job = (GenerateGeodatabaseJob)sender; // Update the progress bar. UpdateProgressBar(job.Progress); }; // Start the job. generateGdbJob.Start(); // Get the result. _resultGdb = await generateGdbJob.GetResultAsync(); // Hide the progress bar. myProgressBar.IsVisible = false; // Handle the job completion. HandleGenerationStatusChange(generateGdbJob); }
private async Task SyncDataAsync(IEnumerable <Geodatabase> syncGeodatabases, SyncDirection syncDirection) { foreach (var geodatabase in syncGeodatabases) { IReadOnlyList <SyncLayerResult> results = null; try { Log.Debug($"{geodatabase.Path} about to start {syncDirection} sync"); if (!geodatabase.HasLocalEdits() && syncDirection == SyncDirection.Upload) { Log.Debug("No edits skipping sync"); continue; } Log.Debug($"ServiceUrl: {geodatabase.Source}"); GeodatabaseSyncTask syncTask = await GeodatabaseSyncTask.CreateAsync(geodatabase.Source); SyncGeodatabaseParameters syncParameters = await syncTask.CreateDefaultSyncGeodatabaseParametersAsync(geodatabase); syncParameters.GeodatabaseSyncDirection = syncDirection; SyncGeodatabaseJob job = syncTask.SyncGeodatabase(syncParameters, geodatabase); results = await job.GetResultAsync(); LogResults(results); } catch (Exception e) { Log.Error(e.Message); Log.Error($"{geodatabase.Path} did not sync"); if (results != null) { LogResults(results); } } } if (syncDirection == SyncDirection.Bidirectional || syncDirection == SyncDirection.Download) { EventAggregator.GetEvent <SyncCompleteEvent>().Publish(SyncCompleteEventArgs.Empty); } }
/// <summary> /// /// </summary> /// <param name="map"></param> /// <returns></returns> public async Task <string> DeleteReplicaAsync(Map map) { var sb = new StringBuilder(); var geodatabases = GetGeodatabases(map); if (geodatabases.Any()) { foreach (var gdb in geodatabases) { var syncId = Guid.Empty; try { syncId = gdb.SyncId; var task = await GeodatabaseSyncTask.CreateAsync(gdb.Source); await task.UnregisterGeodatabaseAsync(gdb); gdb.Close(); sb.Append($"{AppResources.DeleteReplicaMessageDeleted} {syncId}."); } catch (ArcGISWebException ex) { Debug.WriteLine(ex.Message); sb.Append($"{AppResources.DeleteReplicaMessageCantDelete} {syncId}."); } catch { throw; } finally { gdb.Close(); sb.Append($"{AppResources.DeleteReplicaMessageDone}."); } } } await DeleteReplicaFolderAsync(); return(sb.ToString()); }
private async Task SyncGeodatabaes(SyncDirection syncDirection) { foreach (var gdbPath in BidirectionalGdbs) { Geodatabase geodatabase = null; IReadOnlyList <SyncLayerResult> results = null; try { geodatabase = await Geodatabase.OpenAsync(gdbPath); Log.Debug($"{geodatabase.Path} about to start {syncDirection} sync"); if (!geodatabase.HasLocalEdits() && syncDirection == SyncDirection.Upload) { Log.Debug("No edits skipping sync"); continue; } Log.Debug($"ServiceUrl: {geodatabase.Source}"); GeodatabaseSyncTask syncTask = await GeodatabaseSyncTask.CreateAsync(geodatabase.Source); SyncGeodatabaseParameters syncParameters = await syncTask.CreateDefaultSyncGeodatabaseParametersAsync(geodatabase); syncParameters.GeodatabaseSyncDirection = syncDirection; SyncGeodatabaseJob job = syncTask.SyncGeodatabase(syncParameters, geodatabase); results = await job.GetResultAsync(); LogResults(results); } catch (Exception e) { Log.Error(e.Message); Log.Error($"{geodatabase?.Path} did not sync"); LogResults(results); } } }
private async Task StartGeodatabaseGeneration() { // Create a task for generating a geodatabase (GeodatabaseSyncTask). _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri); // Get the (only) graphic in the map view. Graphic redPreviewBox = MyMapView.GraphicsOverlays.First().Graphics.First(); // Get the current extent of the red preview box. Envelope extent = redPreviewBox.Geometry as Envelope; // Get the default parameters for the generate geodatabase task. GenerateGeodatabaseParameters generateParams = await _gdbSyncTask.CreateDefaultGenerateGeodatabaseParametersAsync(extent); // Create a generate geodatabase job. GenerateGeodatabaseJob generateGdbJob = _gdbSyncTask.GenerateGeodatabase(generateParams, _gdbPath); // Handle the progress changed event with an inline (lambda) function to show the progress bar. generateGdbJob.ProgressChanged += (sender, e) => { // Update the progress bar. UpdateProgressBar(generateGdbJob.Progress); }; // Show the progress bar. MyProgressBar.Visibility = Visibility.Visible; // Start the job. generateGdbJob.Start(); // Get the result of the job. _resultGdb = await generateGdbJob.GetResultAsync(); // Hide the progress bar. MyProgressBar.Visibility = Visibility.Collapsed; // Do the rest of the work. HandleGenerationCompleted(generateGdbJob); }
private async Task StartGeodatabaseGeneration() { _generateButton.Enabled = false; // Update geodatabase path. _gdbPath = $"{Path.GetTempFileName()}.geodatabase"; // Create a task for generating a geodatabase (GeodatabaseSyncTask). _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri); // Get the (only) graphic in the map view. Graphic redPreviewBox = _myMapView.GraphicsOverlays.First().Graphics.First(); // Get the current extent of the red preview box. Envelope extent = redPreviewBox.Geometry as Envelope; // Get the default parameters for the generate geodatabase task. GenerateGeodatabaseParameters generateParams = await _gdbSyncTask.CreateDefaultGenerateGeodatabaseParametersAsync(extent); // Create a generate geodatabase job. _gdbGenJob = _gdbSyncTask.GenerateGeodatabase(generateParams, _gdbPath); // Handle the progress changed event. _gdbGenJob.ProgressChanged += GenerateGdbJob_ProgressChanged; // Show the progress bar. _progressBar.Hidden = false; // Start the job. _gdbGenJob.Start(); // Get the result. _resultGdb = await _gdbGenJob.GetResultAsync(); // Do the rest of the work. HandleGenerationCompleted(_gdbGenJob); }
private async void CreateOfflineData() { // create a new GeodatabaseSyncTask to create a local version of feature service data var featureServiceUri = new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Sync/SaveTheBaySync/FeatureServer"); var gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(featureServiceUri); // define an extent for the features to include Envelope extent = mv.GetCurrentViewpoint(ViewpointType.BoundingGeometry).TargetGeometry as Envelope; // get the default parameters for generating a geodatabase var generateGdbParams = await gdbSyncTask.CreateDefaultGenerateGeodatabaseParametersAsync(extent); // set the sync model to per layer generateGdbParams.SyncModel = SyncModel.Layer; // define the layers and features to include var marineLayerId = 0; var birdsLayerId = 1; var dolphinsOnlyWhereClause = "type = 11"; // Clear and re-create the layer options generateGdbParams.LayerOptions.Clear(); generateGdbParams.LayerOptions.Add(new GenerateLayerOption(marineLayerId, dolphinsOnlyWhereClause)); generateGdbParams.LayerOptions.Add(new GenerateLayerOption(birdsLayerId)); // do not return attachments generateGdbParams.ReturnAttachments = false; // create the generate geodatabase job, pass in the parameters and an output path for the local geodatabase var generateGdbJob = gdbSyncTask.GenerateGeodatabase(generateGdbParams, outGeodatabasePath); // handle the JobChanged event to check the status of the job generateGdbJob.JobChanged += OnGenerateGdbJobChanged; // start the job and report the job ID generateGdbJob.Start(); Console.WriteLine("Submitted job #" + generateGdbJob.ServerJobId + " to create local geodatabase"); }
private async Task GetLocalGeodatabase() { // Get the path to the local geodatabase for this platform (temp directory, for example) string localGeodatabasePath = GetGdbPath(); try { // See if the geodatabase file is already present if (File.Exists(localGeodatabasePath)) { // If the geodatabase is already available, open it, hide the progress control, and update the message _localGeodatabase = await Geodatabase.OpenAsync(localGeodatabasePath); _progressBar.Visibility = Android.Views.ViewStates.Gone; _messageTextBlock.Text = "Using local geodatabase from '" + _localGeodatabase.Path + "'"; } else { // Create a new GeodatabaseSyncTask with the uri of the feature server to pull from GeodatabaseSyncTask gdbTask = await GeodatabaseSyncTask.CreateAsync(new Uri(SyncServiceUrl)); // Create parameters for the task: layers and extent to include, out spatial reference, and sync model GenerateGeodatabaseParameters gdbParams = await gdbTask.CreateDefaultGenerateGeodatabaseParametersAsync(_extent); gdbParams.OutSpatialReference = _mapView.SpatialReference; gdbParams.SyncModel = SyncModel.Layer; gdbParams.LayerOptions.Clear(); gdbParams.LayerOptions.Add(new GenerateLayerOption(0)); gdbParams.LayerOptions.Add(new GenerateLayerOption(1)); // Create a geodatabase job that generates the geodatabase GenerateGeodatabaseJob generateGdbJob = gdbTask.GenerateGeodatabase(gdbParams, localGeodatabasePath); // Handle the job changed event and check the status of the job; store the geodatabase when it's ready generateGdbJob.JobChanged += (s, e) => { // Call a function to update the progress bar RunOnUiThread(() => UpdateProgressBar(generateGdbJob.Progress)); // See if the job succeeded if (generateGdbJob.Status == JobStatus.Succeeded) { RunOnUiThread(() => { // Hide the progress control and update the message _progressBar.Visibility = Android.Views.ViewStates.Gone; _messageTextBlock.Text = "Created local geodatabase"; }); } else if (generateGdbJob.Status == JobStatus.Failed) { RunOnUiThread(() => { // Hide the progress control and report the exception _progressBar.Visibility = Android.Views.ViewStates.Gone; _messageTextBlock.Text = "Unable to create local geodatabase: " + generateGdbJob.Error.Message; }); } }; // Start the generate geodatabase job _localGeodatabase = await generateGdbJob.GetResultAsync(); } } catch (Exception ex) { // Show a message for the exception encountered RunOnUiThread(() => { ShowStatusMessage("Generate Geodatabase", "Unable to create offline database: " + ex.Message); }); } }
private async void Initialize() { try { // Create a tile cache from a locally downloaded file. TileCache tileCache = new TileCache(DataManager.GetDataFolder("3f1bbf0ec70b409a975f5c91f363fe7d", "SanFrancisco.tpk")); // Create the corresponding layer based on the tile cache. ArcGISTiledLayer tileLayer = new ArcGISTiledLayer(tileCache); // Create the basemap based on the tile cache. Basemap sfBasemap = new Basemap(tileLayer); // Create the map with the tile-based basemap. Map myMap = new Map(sfBasemap); // Assign the map to the MapView. MyMapView.Map = myMap; // Create a new symbol for the extent graphic. SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Red, 2); // Create graphics overlay for the extent graphic and apply a renderer. GraphicsOverlay extentOverlay = new GraphicsOverlay { Renderer = new SimpleRenderer(lineSymbol) }; // Add graphics overlay to the map view. MyMapView.GraphicsOverlays.Add(extentOverlay); // Set up an event handler for when the viewpoint (extent) changes. MyMapView.ViewpointChanged += UpdateMapExtent; // Create a task for generating a geodatabase (GeodatabaseSyncTask). _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri); // Add all graphics from the service to the map. foreach (IdInfo layer in _gdbSyncTask.ServiceInfo.LayerInfos) { // Create the ServiceFeatureTable for this layer. ServiceFeatureTable onlineTable = new ServiceFeatureTable(new Uri(_featureServiceUri + "/" + layer.Id)); // Wait for the table to load. await onlineTable.LoadAsync(); // Add the layer to the map's operational layers if load succeeds. if (onlineTable.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded) { myMap.OperationalLayers.Add(new FeatureLayer(onlineTable)); } } // Update the graphic - needed in case the user decides not to interact before pressing the button. UpdateMapExtent(null, null); // Enable the generate button. MyGenerateButton.IsEnabled = true; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private async Task GetLocalGeodatabase() { string localGeodatabasePath = GetGdbPath(); try { // See if the geodatabase file is already present. if (File.Exists(localGeodatabasePath)) { // If the geodatabase is already available, open it, hide the progress control, and update the message. _localGeodatabase = await Geodatabase.OpenAsync(localGeodatabasePath); _progressBar.Hidden = true; _statusLabel.Text = "Using local geodatabase."; } else { // Create a new GeodatabaseSyncTask with the URI of the feature server to pull from. Uri uri = new Uri(SyncServiceUrl); GeodatabaseSyncTask gdbTask = await GeodatabaseSyncTask.CreateAsync(uri); // Create parameters for the task: layers and extent to include, out spatial reference, and sync model. GenerateGeodatabaseParameters gdbParams = await gdbTask.CreateDefaultGenerateGeodatabaseParametersAsync(_extent); gdbParams.OutSpatialReference = _mapView.SpatialReference; gdbParams.SyncModel = SyncModel.Layer; gdbParams.LayerOptions.Clear(); gdbParams.LayerOptions.Add(new GenerateLayerOption(0)); gdbParams.LayerOptions.Add(new GenerateLayerOption(1)); // Create a geodatabase job that generates the geodatabase. GenerateGeodatabaseJob generateGdbJob = gdbTask.GenerateGeodatabase(gdbParams, localGeodatabasePath); // Handle the job changed event and check the status of the job; store the geodatabase when it's ready. generateGdbJob.JobChanged += (s, e) => { // Call a function to update the progress bar. InvokeOnMainThread(() => UpdateProgressBar(generateGdbJob.Progress)); switch (generateGdbJob.Status) { // See if the job succeeded. case JobStatus.Succeeded: InvokeOnMainThread(() => { // Hide the progress control and update the message. _progressBar.Hidden = true; _statusLabel.Text = "Created local geodatabase"; }); break; case JobStatus.Failed: InvokeOnMainThread(() => { // Hide the progress control and report the exception. _progressBar.Hidden = true; _statusLabel.Text = "Unable to create local geodatabase: " + generateGdbJob.Error.Message; }); break; } }; // Start the generate geodatabase job. _localGeodatabase = await generateGdbJob.GetResultAsync(); } } catch (Exception ex) { // Show a message for the exception encountered. InvokeOnMainThread(() => { ShowMessage("Generate Geodatabase", "Unable to create offline database: " + ex.Message, "OK"); }); } }
private async void Initialize() { try { // Create a tile cache and load it with the SanFrancisco streets tpk. TileCache tileCache = new TileCache(DataManager.GetDataFolder("3f1bbf0ec70b409a975f5c91f363fe7d", "SanFrancisco.tpk")); // Create the corresponding layer based on the tile cache. ArcGISTiledLayer tileLayer = new ArcGISTiledLayer(tileCache); // Create the basemap based on the tile cache. Basemap sfBasemap = new Basemap(tileLayer); // Create the map with the tile-based basemap. Map map = new Map(sfBasemap); // Assign the map to the MapView. _myMapView.Map = map; // Create a new symbol for the extent graphic. SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Red, 2); // Create graphics overlay for the extent graphic and apply a renderer. GraphicsOverlay extentOverlay = new GraphicsOverlay { Renderer = new SimpleRenderer(lineSymbol) }; // Add graphics overlay to the map view. _myMapView.GraphicsOverlays.Add(extentOverlay); // Create a task for generating a geodatabase (GeodatabaseSyncTask). _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri); // Add all graphics from the service to the map. foreach (IdInfo layer in _gdbSyncTask.ServiceInfo.LayerInfos) { // Get the Uri for this particular layer. Uri onlineTableUri = new Uri(_featureServiceUri + "/" + layer.Id); // Create the ServiceFeatureTable. ServiceFeatureTable onlineTable = new ServiceFeatureTable(onlineTableUri); // Wait for the table to load. await onlineTable.LoadAsync(); // Skip tables that aren't for point features.{ if (onlineTable.GeometryType != GeometryType.Point) { continue; } // Add the layer to the map's operational layers if load succeeds. if (onlineTable.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded) { map.OperationalLayers.Add(new FeatureLayer(onlineTable)); } } // Update the graphic - needed in case the user decides not to interact before pressing the button. UpdateMapExtent(); // Enable the generate button now that the sample is ready. _generateButton.Enabled = true; } catch (Exception ex) { ShowStatusMessage(ex.ToString()); } }
private async Task GetLocalGeodatabase() { // Get the path to the local geodatabase for this platform (temp directory, for example) var localGeodatabasePath = GetGdbPath(); try { // See if the geodatabase file is already present if (File.Exists(localGeodatabasePath)) { // If the geodatabase is already available, open it, hide the progress control, and update the message _localGeodatabase = await Geodatabase.OpenAsync(localGeodatabasePath); LoadingProgressBar.Visibility = Visibility.Collapsed; MessageTextBlock.Text = "Using local geodatabase from '" + _localGeodatabase.Path + "'"; } else { // Create a new GeodatabaseSyncTask with the uri of the feature server to pull from var uri = new Uri(SyncServiceUrl); var gdbTask = await GeodatabaseSyncTask.CreateAsync(uri); // Create parameters for the task: layers and extent to include, out spatial reference, and sync model var gdbParams = await gdbTask.CreateDefaultGenerateGeodatabaseParametersAsync(_extent); gdbParams.OutSpatialReference = MyMapView.SpatialReference; gdbParams.SyncModel = SyncModel.Layer; gdbParams.LayerOptions.Clear(); gdbParams.LayerOptions.Add(new GenerateLayerOption(0)); gdbParams.LayerOptions.Add(new GenerateLayerOption(1)); // Create a geodatabase job that generates the geodatabase GenerateGeodatabaseJob generateGdbJob = gdbTask.GenerateGeodatabase(gdbParams, localGeodatabasePath); // Handle the job changed event and check the status of the job; store the geodatabase when it's ready generateGdbJob.JobChanged += (s, e) => { // See if the job succeeded if (generateGdbJob.Status == JobStatus.Succeeded) { this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { // Hide the progress control and update the message LoadingProgressBar.Visibility = Visibility.Collapsed; MessageTextBlock.Text = "Created local geodatabase"; }); } else if (generateGdbJob.Status == JobStatus.Failed) { this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { // Hide the progress control and report the exception LoadingProgressBar.Visibility = Visibility.Collapsed; MessageTextBlock.Text = "Unable to create local geodatabase: " + generateGdbJob.Error.Message; }); } }; // Start the generate geodatabase job _localGeodatabase = await generateGdbJob.GetResultAsync(); } } catch (Exception ex) { // Show a message for the exception encountered this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { MessageDialog dialog = new MessageDialog("Unable to create offline database: " + ex.Message); dialog.ShowAsync(); }); } }
public static async Task <Geodatabase> DownloadOrUpdateFeatureService(String serviceUrl, Extent extent, Action <double, double> ProgressUpdate) { var task = new TaskCompletionSource <Geodatabase>(); var syncTask = await GeodatabaseSyncTask.CreateAsync(new Uri(serviceUrl)); var serviceName = PullArcgisServiceName(serviceUrl); var geodatabaseFilePath = Path.Combine(CachePath, serviceName + ".gdb"); Geodatabase ret; if (File.Exists(geodatabaseFilePath)) { //add service to existing mobile geodatabase ret = await Geodatabase.OpenAsync(geodatabaseFilePath); // create sync parameters var taskParameters = new SyncGeodatabaseParameters() { RollbackOnFailure = true, GeodatabaseSyncDirection = SyncDirection.Download }; // create a synchronize geodatabase job, pass in the parameters and the geodatabase SyncGeodatabaseJob syncGdbJob = syncTask.SyncGeodatabase(taskParameters, ret); syncGdbJob.JobChanged += (async(object sender, EventArgs e) => { var job = sender as SyncGeodatabaseJob; switch (job?.Status) { case JobStatus.Succeeded: await syncTask.UnregisterGeodatabaseAsync(ret); task.SetResult(ret); break; case JobStatus.Failed: if (job.Error != null) { task.SetException(job.Error); } else { String message = string.Empty; var m = from msg in job.Messages select msg.Message; message += ": " + string.Join <string>("\n", m); task.SetException(new Exception(message)); } task.SetResult(null); break; } }); syncGdbJob.ProgressChanged += ((object sender, EventArgs e) => { ProgressUpdate?.Invoke(syncGdbJob.Progress, 1.0); }); // Start the job var result = await syncGdbJob.GetResultAsync(); } else { var envelope = new Envelope(extent.MinX, extent.MinY, extent.MaxX, extent.MaxY, SpatialReference.Create(extent.WKID)); // Get the default parameters for the generate geodatabase task GenerateGeodatabaseParameters generateParams = await syncTask.CreateDefaultGenerateGeodatabaseParametersAsync(envelope); // Create a generate geodatabase job var generateGdbJob = syncTask.GenerateGeodatabase(generateParams, geodatabaseFilePath); // Handle the job changed event generateGdbJob.JobChanged += (async(object sender, EventArgs e) => { var job = sender as GenerateGeodatabaseJob; switch (job?.Status) { case JobStatus.Succeeded: ret = await job.GetResultAsync(); await syncTask.UnregisterGeodatabaseAsync(ret); task.SetResult(ret); break; case JobStatus.Failed: if (job.Error != null) { task.SetException(job.Error); } else { String message = string.Empty; var m = from msg in job.Messages select msg.Message; message += ": " + string.Join <string>("\n", m); task.SetException(new Exception(message)); } task.SetResult(null); break; } }); // Handle the progress changed event (to show progress bar) generateGdbJob.ProgressChanged += ((object sender, EventArgs e) => { ProgressUpdate?.Invoke(generateGdbJob.Progress, 1.0); }); // Start the job generateGdbJob.Start(); } return(await task.Task); }
private async void Initialize() { // Create a tile cache and load it with the SanFrancisco streets tpk. try { TileCache tileCache = new TileCache(DataManager.GetDataFolder("e4a398afe9a945f3b0f4dca1e4faccb5", "SanFrancisco.tpkx")); // Create the corresponding layer based on the tile cache. ArcGISTiledLayer tileLayer = new ArcGISTiledLayer(tileCache); // Create the basemap based on the tile cache. Basemap sfBasemap = new Basemap(tileLayer); // Create the map with the tile-based basemap. Map myMap = new Map(sfBasemap); // Assign the map to the MapView. myMapView.Map = myMap; // Create a new symbol for the extent graphic. SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Colors.Red, 2); // Create a graphics overlay for the extent graphic and apply a renderer. GraphicsOverlay extentOverlay = new GraphicsOverlay { Renderer = new SimpleRenderer(lineSymbol) }; // Add the graphics overlay to the map view. myMapView.GraphicsOverlays.Add(extentOverlay); // Set up an event handler for when the viewpoint (extent) changes. myMapView.ViewpointChanged += MapViewExtentChanged; // Create a task for generating a geodatabase (GeodatabaseSyncTask). _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri); // Add all layers from the service to the map. foreach (IdInfo layer in _gdbSyncTask.ServiceInfo.LayerInfos) { // Get the URL for this layer. Uri onlineTableUri = new Uri(_featureServiceUri + "/" + layer.Id); // Create the ServiceFeatureTable. ServiceFeatureTable onlineTable = new ServiceFeatureTable(onlineTableUri); // Wait for the table to load. await onlineTable.LoadAsync(); // Skip tables that aren't for point features.{ if (onlineTable.GeometryType != GeometryType.Point) { continue; } // Add the layer to the map's operational layers if load succeeds. if (onlineTable.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded) { myMap.OperationalLayers.Add(new FeatureLayer(onlineTable)); } } // Update the graphic - needed in case the user decides not to interact before pressing the button. UpdateMapExtent(); // Enable the generate button now that sample is ready. myGenerateButton.IsEnabled = true; } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.ToString(), "OK"); } }