Click or drag to resize

TileCache Class

Metadata for a local on-disk cache of pre-rendered map tiles that can be used to create a layer.
Inheritance Hierarchy
SystemObject
  Esri.ArcGISRuntime.MappingTileCache

Namespace:  Esri.ArcGISRuntime.Mapping
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.7.0.0
Syntax
C#
public sealed class TileCache : ILoadable

The TileCache type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleTileCache
Initializes a new instance of the TileCache class.
Top
Properties
  NameDescription
Public propertyAntialiasing
Gets a value indicating whether this cache uses antialiasing.
Public propertyCacheStorageFormat
Gets the storage format of this tile cache.
Public propertyFullExtent
Gets the full extent of the tile cache.
Public propertyLoadError
Gets the load error for this instance - if any.
Public propertyLoadStatus
Gets the load status of the instance.
Public propertyPath
Gets the path of the tile cache.
Public propertyThumbnail
Gets the thumbnail image of this tile cache.
Public propertyThumbnailData
Gets the thumbnail image of this tile cache.
Public propertyTileInfo
Gets the tile scheme information used by this tile cache.
Top
Methods
  NameDescription
Public methodCancelLoad
Cancels an ongoing load.
Public methodClone
Clones this instance of the tile cache and its members.
Public methodGetTileData
Returns the tile data for the specified tile key.
Public methodCode exampleLoadAsync
Initiates loading of metadata for this instance
Public methodRetryLoadAsync
Retry loading metadata for the instance.
Top
Events
  NameDescription
Public eventLoaded
Occurs when this instance is loaded.
Public eventLoadStatusChanged
Occurs when the instance's LoadStatus has changed.
Top
Remarks

Local tile caches are ideal for providing basemaps or less frequently changing contextual layers, where network access is limited or non-existent. They can be created and downloaded onto a device by using an ExportTileCacheJob, or alternatively can be provisioned directly to local storage.

The supported types of cache are:

  • Tile package(.tpk or .tpkx) - a map and the tile cache of the data contained within it, packaged into one convenient, portable file, ideal for offline sharing or complete map documents in a disconnected environment or via a portal.
  • Compact Cache - a directory structure where groups of tiles are combined into larger.bundle files, preserving performance and reducing copy times and the size on disk of the cache.
  • Exploded Cache - a directory structure where map tiles are stored as individual files. A TileCache is often used as a basemap, but can also be used to create an ArcGISTiledLayer that is added to a map as an operational layer.
Examples

Android

Example Name: CreateTerrainSurfaceFromTilePackage

Set the terrain surface with elevation described by a local tile package.

Code example screen shot.

C#
// Copyright 2019 Esri.
// 
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an 
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 
// language governing permissions and limitations under the License.

using Android.App;
using Android.OS;
using Android.Widget;
using ArcGISRuntime.Samples.Managers;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.UI.Controls;

namespace ArcGISRuntimeXamarin.Samples.CreateTerrainSurfaceFromTilePackage
{
    [Activity (ConfigurationChanges=Android.Content.PM.ConfigChanges.Orientation | Android.Content.PM.ConfigChanges.ScreenSize)]
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        "Create terrain surface from a tile package",
        "Map",
        "Use a terrain surface with elevation described by a local tile package.",
        "")]
    [ArcGISRuntime.Samples.Shared.Attributes.OfflineData("cce37043eb0440c7a5c109cf8aad5500")]
    public class CreateTerrainSurfaceFromTilePackage : Activity
    {
        // Hold references to the UI controls.
        private SceneView _mySceneView;

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            Title = "Create terrain surface from a tile package";

            CreateLayout();
            Initialize();
        }

        private void Initialize()
        {
            // Create the scene.
            _mySceneView.Scene = new Scene(Basemap.CreateImagery());

            // Get the path to the elevation tile package.
            string packagePath = DataManager.GetDataFolder("cce37043eb0440c7a5c109cf8aad5500", "MontereyElevation.tpk");

            // Create the elevation source from the tile cache.
            TileCache elevationCache = new TileCache(packagePath);
            ArcGISTiledElevationSource elevationSource = new ArcGISTiledElevationSource(elevationCache);

            // Create a surface to display the elevation source.
            Surface elevationSurface = new Surface();

            // Add the elevation source to the surface.
            elevationSurface.ElevationSources.Add(elevationSource);

            // Add the surface to the scene.
            _mySceneView.Scene.BaseSurface = elevationSurface;

            // Set an initial camera viewpoint.
            Camera camera = new Camera(36.525, -121.80, 300.0, 180, 80.0, 0.0);
            _mySceneView.SetViewpointCamera(camera);
        }

        private void CreateLayout()
        {
            // Create a new vertical layout for the app.
            var layout = new LinearLayout(this) {Orientation = Orientation.Vertical};

            // Add the map view to the layout.
            _mySceneView = new SceneView(this);
            layout.AddView(_mySceneView);

            // Show the layout in the app.
            SetContentView(layout);
        }
    }
}
Examples

Xamarin Forms Android

Example Name: CreateTerrainSurfaceFromTilePackage

Set the terrain surface with elevation described by a local tile package.

Code example screen shot.

C#
// Copyright 2019 Esri.
// 
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an 
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 
// language governing permissions and limitations under the License.

using ArcGISRuntime.Samples.Managers;
using Esri.ArcGISRuntime.Mapping;
using Xamarin.Forms;

namespace ArcGISRuntimeXamarin.Samples.CreateTerrainSurfaceFromTilePackage
{
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        "Create terrain surface from a tile package",
        "Map",
        "Use a terrain surface with elevation described by a local tile package.",
        "")]
    [ArcGISRuntime.Samples.Shared.Attributes.OfflineData("cce37043eb0440c7a5c109cf8aad5500")]
    public partial class CreateTerrainSurfaceFromTilePackage : ContentPage
    {
        public CreateTerrainSurfaceFromTilePackage()
        {
            InitializeComponent();
            Initialize();
        }

        private void Initialize()
        {
            // Create the scene.
            MySceneView.Scene = new Scene(Basemap.CreateImagery());

            // Get the path to the elevation tile package.
            string packagePath = DataManager.GetDataFolder("cce37043eb0440c7a5c109cf8aad5500", "MontereyElevation.tpk");

            // Create the elevation source from the tile cache.
            TileCache elevationCache = new TileCache(packagePath);
            ArcGISTiledElevationSource elevationSource = new ArcGISTiledElevationSource(elevationCache);

            // Create a surface to display the elevation source.
            Surface elevationSurface = new Surface();

            // Add the elevation source to the surface.
            elevationSurface.ElevationSources.Add(elevationSource);

            // Add the surface to the scene.
            MySceneView.Scene.BaseSurface = elevationSurface;

            // Set an initial camera viewpoint.
            Camera camera = new Camera(36.525, -121.80, 300.0, 180, 80.0, 0.0);
            MySceneView.SetViewpointCamera(camera);
        }
    }
}
XAML
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Xamarin.Forms"
             x:Class="ArcGISRuntimeXamarin.Samples.CreateTerrainSurfaceFromTilePackage.CreateTerrainSurfaceFromTilePackage">
    <Grid>
        <esriUI:SceneView x:Name="MySceneView" />
    </Grid>
</ContentPage>
See Also
Additional Examples
Hyperlink to ExampleDescription
CreateTerrainSurfaceFromTilePackageSet the terrain surface with elevation described by a local tile package.
EditAndSyncFeaturesSynchronize offline edits with a feature service.
ExportTilesDownload tiles to a local tile cache file stored on the device.
GenerateGeodatabaseGenerate a local geodatabase from an online feature service.
OfflineGeocodeGeocode addresses to locations and reverse geocode locations to addresses offline.
OfflineRoutingSolve a route on-the-fly using offline data.