internal void Initialize(IMap map, UnwrappedTileId tileId) { _relativeScale = 1 / Mathf.Cos(Mathf.Deg2Rad * (float)map.CenterLatitudeLongitude.x); _rect = Conversions.TileBounds(tileId); _canonicalTileId = tileId.Canonical; var position = new Vector3((float)(Rect.Center.x - map.CenterMercator.x), 0, (float)(Rect.Center.y - map.CenterMercator.y)); gameObject.name = tileId.ToString(); transform.localPosition = position; gameObject.SetActive(true); }
internal void Initialize(IMap map, UnwrappedTileId tileId) { _relativeScale = 1 / Mathf.Cos(Mathf.Deg2Rad * (float)map.CenterLatitudeLongitude.x); _rect = Conversions.TileBounds(tileId); _canonicalTileId = tileId.Canonical; // previous implementation. This is done this way, custom for each tile // since we cannot tell where to place each tile according to the // center of the map (rather than find the center tile id, then offset // each of the tiles taking the x- and y- difference in the id //var position = new Vector3((float)(Rect.Center.x - map.CenterMercator.x), 0, (float)(Rect.Center.y - map.CenterMercator.y)); // zoom, x, y UnwrappedTileId centerTileId = CustomMap.Instance.CenterTileId; int xOffset = tileId.X - centerTileId.X; int yOffset = tileId.Y - centerTileId.Y; Vector3 position = new Vector3(xOffset * CustomMap.Instance.UnityTileLocalSize, 0, -yOffset * CustomMap.Instance.UnityTileLocalSize); gameObject.name = tileId.ToString(); transform.localPosition = position; gameObject.SetActive(true); gameObject.AddComponent <Interpolator>(); }