private ExportTileCacheParameters GetExportParameters() { // Create a new parameters instance. ExportTileCacheParameters parameters = new ExportTileCacheParameters(); // Get the (only) graphics overlay in the map view. GraphicsOverlay extentOverlay = MyMapView.GraphicsOverlays.First(); // Get the area selection graphic's extent. Graphic extentGraphic = extentOverlay.Graphics.First(); // Set the area for the export. parameters.AreaOfInterest = extentGraphic.Geometry; // Set the highest possible export quality. parameters.CompressionQuality = 100; // Add level IDs 1-9. // Note: Failing to add at least one Level ID will result in job failure. for (int x = 1; x < 10; x++) { parameters.LevelIds.Add(x); } // Return the parameters. return(parameters); }
private void ConfigureTileLayerOverrides(GenerateOfflineMapParameterOverrides overrides) { // Create a parameter key for the first basemap layer. OfflineMapParametersKey basemapKey = new OfflineMapParametersKey(MyMapView.Map.Basemap.BaseLayers.First()); // Get the export tile cache parameters for the layer key. ExportTileCacheParameters basemapParams = overrides.ExportTileCacheParameters[basemapKey]; // Clear the existing level IDs. basemapParams.LevelIds.Clear(); // Get the min and max scale from the UI. int minScale = (int)MinScaleEntry.Value; int maxScale = (int)MaxScaleEntry.Value; // Re-add selected scales. for (int i = minScale; i < maxScale; i++) { basemapParams.LevelIds.Add(i); } // Expand the area of interest based on the specified buffer distance. int bufferDistance = (int)ExtentBufferEntry.Value; basemapParams.AreaOfInterest = GeometryEngine.BufferGeodetic(_areaOfInterest, bufferDistance, LinearUnits.Meters); }
/// <summary> /// Starts the export job and registers callbacks to be notified of changes to job status /// </summary> private async void StartExport() { // Update the tile cache path _tilePath = GetTilePath(); // Get the parameters for the job ExportTileCacheParameters parameters = GetExportParameters(); // Create the task ExportTileCacheTask exportTask = await ExportTileCacheTask.CreateAsync(_serviceUri); // Create the export job ExportTileCacheJob job = exportTask.ExportTileCache(parameters, _tilePath); // Subscribe to notifications for status updates job.JobChanged += Job_JobChanged; // Start the export job job.Start(); }
private void ConfigureTileLayerOverrides() { // Create a parameter key for the first basemap layer. OfflineMapParametersKey basemapKey = new OfflineMapParametersKey(_map.Basemap.BaseLayers.First()); // Get the export tile cache parameters for the layer key. ExportTileCacheParameters basemapParams = _overrides.ExportTileCacheParameters[basemapKey]; // Clear the existing level IDs. basemapParams.LevelIds.Clear(); // Re-add selected scales. for (int i = _minScale; i < _maxScale; i++) { basemapParams.LevelIds.Add(i); } // Expand the area of interest based on the specified buffer distance. basemapParams.AreaOfInterest = GeometryEngine.BufferGeodetic(_areaOfInterest, _bufferExtent, LinearUnits.Meters); }
private async Task ExportTilesAsync(Geometry area, string downloadFolderPath, Uri uri) { var offlineTask = await ExportTileCacheTask.CreateAsync(uri); var parameters = new ExportTileCacheParameters { AreaOfInterest = area, CompressionQuality = 100 }; parameters.LevelIds.Add(4); parameters.LevelIds.Add(6); parameters.LevelIds.Add(8); parameters.LevelIds.Add(12); var job = offlineTask.ExportTileCache(parameters, downloadFolderPath + ".tpk"); job.Start(); await job.GetResultAsync(); }
private async Task StartExport() { // Get the parameters for the job. ExportTileCacheParameters parameters = GetExportParameters(); // Create the task. ExportTileCacheTask exportTask = await ExportTileCacheTask.CreateAsync(_serviceUri); // Get the tile cache path. _tilePath = $"{Path.GetTempFileName()}.tpk"; // Create the export job. ExportTileCacheJob job = exportTask.ExportTileCache(parameters, _tilePath); // Start the export job. job.Start(); // Get the result. TileCache cache = await job.GetResultAsync(); // Do the rest of the work. await HandleExportComplete(job, cache); }
private async Task StartExport() { // Get the parameters for the job. ExportTileCacheParameters parameters = GetExportParameters(); // Create the task. ExportTileCacheTask exportTask = await ExportTileCacheTask.CreateAsync(_serviceUri); // Get the tile cache path. string tilePath = Path.Combine(Environment.ExpandEnvironmentVariables("%TEMP%"), Path.GetTempFileName() + ".tpk"); // Create the export job. ExportTileCacheJob job = exportTask.ExportTileCache(parameters, tilePath); // Start the export job. job.Start(); // Wait for the job to complete. TileCache resultTileCache = await job.GetResultAsync(); // Do the rest of the work. await HandleExportCompleted(job, resultTileCache); }
private async Task StartExport() { try { // Update the tile cache path. _tilePath = $"{Path.GetTempFileName()}.tpk"; // Get the parameters for the job. ExportTileCacheParameters parameters = GetExportParameters(); // Create the task. ExportTileCacheTask exportTask = await ExportTileCacheTask.CreateAsync(_serviceUri); // Create the export job. ExportTileCacheJob job = exportTask.ExportTileCache(parameters, _tilePath); // Show the progress bar. MyProgressBar.IsVisible = true; // Start the export job. job.Start(); // Get the tile cache result. TileCache resultTileCache = await job.GetResultAsync(); // Hide the progress bar. MyProgressBar.IsVisible = false; // Do the rest of the work. await HandleJobCompletion(job, resultTileCache); } catch (Exception ex) { await((Page)Parent).DisplayAlert("Error", ex.ToString(), "OK"); } }