private void ConstructInternal() { var converter = new MapPixelConverter(); var tileStep = mapViewContext.TileResolution * converter.GetZoomMultiplier(zoomLevel); var cut = mapViewContext.Cut; var startLocation = initLocation + new PixelLocation(-1, 1) * (int)(tileStep * 0.5F * (cut - 1)); var levelStep = tileStep * cut; var tileScale = 1F / cut; Func <int, float> place = (index) => (tileScale - 1F) * 0.5F + tileScale * index; Func <int, int, int> locationPlace = (center, index) => (int)(center + tileStep * index); var mapLevelContext = new MapLevelContext(zoomLevel, levelStep, tileScale); var mapTileFactory = new MapTileFactory(tileRefObject, mapLevelContext, mapTileUpdater); for (var x = 0; x < cut; ++x) { for (var z = 0; z < cut; ++z) { var location = new PixelLocation() { X = locationPlace(startLocation.X, x), Z = locationPlace(startLocation.Z, -z) }; var tile = mapTileFactory.GetMapTile(); tile.gameObject.SetParent(gameObject); tile.transform.localPosition = new Vector3(place(x), 0F, place(z)); tile.transform.localScale = Vector3.one * tileScale; tile.Construct(location); tiles.Add(tile); } } }
public IEnumerator UpdateTile(MapTile tile) { var converter = new MapPixelConverter(); var longitude = converter.XToLon(tile.Location.X); var latitude = converter.ZToLat(tile.Location.Z); var resolution = mapContext.TileResolution; var mapRequest = new YandexMapRequest(latitude, longitude, tile.ZoomLevel, resolution); var loadingService = mapContext.MapService; IEnumerator result = null; yield return(result = loadingService.Load(mapRequest.GetUrl())); var data = result.Current as byte[]; if (tile != null && tile.gameObject && data != null) { var applier = new MapTileApplier(); applier.Apply(tile.gameObject, data, resolution); } }
private void Start() { var tileLoadingService = new TileLoadingService(this, mapServiceWaitTime); var mapViewContext = new MapViewContext(cut, tileResolution, tileLoadingService); var mapTileUpdater = new MapTileUpdater(mapViewContext); var converter = new MapPixelConverter(); var pixelLocation = new PixelLocation() { X = converter.LonToX(longitude), Z = converter.LatToZ(latitude) }; var mapLevelFactory = new MapLevelFactory(mapViewContext, mapTileUpdater, tileRefObject, gameObject); mapLevelSpowner = new MapLevelSpowner(mapLevelFactory); mapLevelSpowner.SpownMapLevel(pixelLocation, zoomLevel); collider = GetComponent <Collider>(); InputMaster.Instance.AddPointDragEventHandler(collider, OnPointerDrag); InputMaster.Instance.AddWheelScrollEventHandler(collider, OnScrollWheel); }