I've found some code for Map case:
Map myMap = new Map();
String filepath = "location_of_raster_file" ;
Raster myRasterFile = new Raster(filepath);
RasterLayer myRasterLayer = new RasterLayer(myRasterFile);
await myRasterLayer.LoadAsync();
myMap.Basemap.BaseLayers.Add(myRasterLayer);
But it doesn't work for Scene:
Scene newScene = new Scene();
String filepath = "C:\\Users\\user\\Desktop\\City.tpk";
Raster myRasterFile = new Raster(filepath);
RasterLayer myRasterLayer = new RasterLayer(myRasterFile);
await myRasterLayer.LoadAsync();
newScene.Basemap.BaseLayers.Add(myRasterLayer);
Solved! Go to Solution.
You can also with :
private const string MAP = "map.tpk";
....
.....
Uri uri = new Uri(MAP);
// Create a tile cache from the local data.
TileCache cache = new TileCache(uri.LocalPath);
// Use the tile cache to create an ArcGISTiledLayer.
ArcGISTiledLayer tiledLayer = new ArcGISTiledLayer(cache);
// Display the tiled layer as a basemap.
MyMapView.Map = new Map(new Basemap(tiledLayer));
Hi Vanya Ivanov,
To use a TPK, do not use a RasterLayer. Instead use an ArcGISTiledLayer with a TileCache initialized with the TPK.
See the example here: ArcGISTiledLayer Constructor (TileCache)
Hope this helps.
var tileCache = new TileCache(Constants.Settings.ImageryLocation);
ArcGISTiledLayer imageLayer = new ArcGISTiledLayer(tileCache);
var map = new Esri.ArcGISRuntime.Mapping.Map(new Basemap(imageLayer))
{
InitialViewpoint = new Viewpoint(extent)
};
You can also with :
private const string MAP = "map.tpk";
....
.....
Uri uri = new Uri(MAP);
// Create a tile cache from the local data.
TileCache cache = new TileCache(uri.LocalPath);
// Use the tile cache to create an ArcGISTiledLayer.
ArcGISTiledLayer tiledLayer = new ArcGISTiledLayer(cache);
// Display the tiled layer as a basemap.
MyMapView.Map = new Map(new Basemap(tiledLayer));