-
-
Save garethpaul/ef011393ff4dae45ea5be64ce84a1a66 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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