Skip to content

Instantly share code, notes, and snippets.

@garethpaul
Created July 24, 2017 05:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garethpaul/ef011393ff4dae45ea5be64ce84a1a66 to your computer and use it in GitHub Desktop.
Save garethpaul/ef011393ff4dae45ea5be64ce84a1a66 to your computer and use it in GitHub Desktop.
namespace Mapbox.Unity.Map
{
using UnityEngine;
using Mapbox.Map;
public class RangeTileProvider : AbstractTileProvider
{
[SerializeField]
private int _west;
[SerializeField]
private int _north;
[SerializeField]
private int _east;
[SerializeField]
private int _south;
internal override void OnInitialized()
{
var centerTile = TileCover.CoordinateToTileId(_map.CenterLatitudeLongitude, _map.Zoom);
AddTile(new UnwrappedTileId(_map.Zoom, centerTile.X, centerTile.Y));
for (int x = (int)(centerTile.X - _west); x <= (centerTile.X + _east); x++)
{
for (int y = (int)(centerTile.Y - _north); y <= (centerTile.Y + _south); y++)
{
AddTile(new UnwrappedTileId(_map.Zoom, x, y));
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment