Show / Hide Table of Contents

Class TileCover

Helper funtions to get a tile cover, i.e. a set of tiles needed for covering a bounding box.

Inheritance
System.Object
TileCover
Namespace:Mapbox.Map
Assembly:Mapbox.Map.dll
Syntax
public static class TileCover : object

Methods

CoordinateToTileId(Vector2d, Int32)

Converts a coordinate to a tile identifier.

Declaration
public static UnwrappedTileId CoordinateToTileId(Vector2d coord, int zoom)
Parameters
Type Name Description
Vector2d coord

Geographic coordinate.

System.Int32 zoom

Zoom level.

Returns
Type Description
UnwrappedTileId

The to tile identifier.

Examples

Convert a geocoordinate to a TileId:

var unwrappedTileId = TileCover.CoordinateToTileId(new Vector2d(40.015, -105.2705), 18);
Console.Write("UnwrappedTileId: " + unwrappedTileId.ToString());

Get(Vector2dBounds, Int32)

Get a tile cover for the specified bounds and zoom.

Declaration
public static HashSet<CanonicalTileId> Get(Vector2dBounds bounds, int zoom)
Parameters
Type Name Description
Vector2dBounds bounds

Geographic bounding box.

System.Int32 zoom

Zoom level.

Returns
Type Description
HashSet<CanonicalTileId>

The tile cover set.

Examples

Build a map of Colorado using TileCover:

var sw = new Vector2d(36.997749, -109.0524961);
var ne = new Vector2d(41.0002612, -102.0609668);
var coloradoBounds = new Vector2dBounds(sw, ne);
var tileCover = TileCover.Get(coloradoBounds, 8);
Console.Write("Tiles Needed: " + tileCover.Count);
foreach (var id in tileCover)
{
    var tile = new RasterTile();
    var parameters = new Tile.Parameters();
    parameters.Id = id;
    parameters.Fs = MapboxAccess.Instance;
    parameters.MapId = "mapbox://styles/mapbox/outdoors-v10";
    tile.Initialize(parameters, (Action)(() =>
    {
        // Place tiles and load textures.
    }));
}
Back to top Copyright © 2015-2016 Microsoft
Generated by DocFX