Esempio n. 1
0
        /// <summary>
        /// Sets up map.
        /// This method uses the mapOptions and layer properties to setup the map to be rendered.
        /// Override <c>SetUpMap</c> to write custom behavior to map setup.
        /// </summary>
        protected virtual void SetUpMap()
        {
            switch (_options.placementOptions.placementType)
            {
            case MapPlacementType.AtTileCenter:
                _options.placementOptions.placementStrategy = new MapPlacementAtTileCenterStrategy();
                break;

            case MapPlacementType.AtLocationCenter:
                _options.placementOptions.placementStrategy = new MapPlacementAtLocationCenterStrategy();
                break;

            default:
                _options.placementOptions.placementStrategy = new MapPlacementAtTileCenterStrategy();
                break;
            }

            switch (_options.scalingOptions.scalingType)
            {
            case MapScalingType.WorldScale:
                _options.scalingOptions.scalingStrategy = new MapScalingAtWorldScaleStrategy();
                break;

            case MapScalingType.Custom:
                _options.scalingOptions.scalingStrategy = new MapScalingAtUnityScaleStrategy();
                break;

            default:
                break;
            }
            if (_options.extentOptions.extentType != MapExtentType.Custom)
            {
                ITileProviderOptions tileProviderOptions = _options.extentOptions.GetTileProviderOptions();
                // Setup tileprovider based on type.
                switch (_options.extentOptions.extentType)
                {
                case MapExtentType.CameraBounds:
                    TileProvider = gameObject.AddComponent <QuadTreeTileProvider>();
                    break;

                case MapExtentType.RangeAroundCenter:
                    TileProvider = gameObject.AddComponent <RangeTileProvider>();
                    break;

                case MapExtentType.RangeAroundTransform:
                    TileProvider = gameObject.AddComponent <RangeAroundTransformTileProvider>();
                    break;

                default:
                    break;
                }
                TileProvider.SetOptions(tileProviderOptions);
            }
            else
            {
                TileProvider = _tileProvider;
            }


            if (_imagery == null)
            {
                _imagery = new ImageryLayer();
            }
            _imagery.Initialize();

            if (_terrain == null)
            {
                _terrain = new TerrainLayer();
            }
            _terrain.Initialize();

            if (_vectorData == null)
            {
                _vectorData = new VectorLayer();
            }
            _vectorData.Initialize();

            if (Options.loadingTexture != null)
            {
                _mapVisualizer.SetLoadingTexture(Options.loadingTexture);
            }

            if (Options.tileMaterial != null)
            {
                _mapVisualizer.SetTileMaterial(Options.tileMaterial);
            }

            _mapVisualizer.Factories = new List <AbstractTileFactory>();

            _mapVisualizer.Factories.Add(_terrain.Factory);
            _mapVisualizer.Factories.Add(_imagery.Factory);
            _mapVisualizer.Factories.Add(_vectorData.Factory);

            InitializeMap(_options);
        }