//----------------------------------------------------------------------- // // Copyright (c) 2016 Mapbox. All rights reserved. // //----------------------------------------------------------------------- namespace Mapbox.Map { /// /// A raster tile from the Mapbox Style API, an encoded image representing a geographic /// bounding box. Usually JPEG or PNG encoded. /// /// /// Making a RasterTile request: /// /// var parameters = new Tile.Parameters(); /// parameters.Fs = MapboxAccess.Instance; /// parameters.Id = new CanonicalTileId(_zoom, _tileCoorindateX, _tileCoordinateY); /// parameters.TilesetId = "mapbox://styles/mapbox/satellite-v9"; /// var rasterTile = new RasterTile(); /// /// // Make the request. /// rasterTile.Initialize(parameters, (Action)(() => /// { /// if (!string.IsNullOrEmpty(rasterTile.Error)) /// { /// // Handle the error. /// } /// /// // Consume the . /// })); /// /// public class RasterTile : Tile { private byte[] data; /// Gets the raster tile raw data. /// The raw data, usually an encoded JPEG or PNG. /// /// Consuming data in Unity to create a Texture2D: /// /// var texture = new Texture2D(0, 0); /// texture.LoadImage(rasterTile.Data); /// _sampleMaterial.mainTexture = texture; /// /// public byte[] Data { get { return this.data; } } internal override TileResource MakeTileResource(string tilesetId) { return TileResource.MakeRaster(Id, tilesetId); } internal override bool ParseTileData(byte[] data) { // We do not parse raster tiles as they are this.data = data; return true; } } }