Exemple #1
0
        internal override void OnRegistered(UnityTile tile)
        {
            var vectorTile = new VectorTile();

            tile.AddTile(vectorTile);


            vectorTile.Initialize(_fileSource, tile.CanonicalTileId, _mapId, () =>
            {
                if (tile == null)
                {
                    return;
                }

                if (vectorTile.HasError)
                {
                    OnErrorOccurred(new TileErrorEventArgs(tile.CanonicalTileId, vectorTile.GetType(), tile, vectorTile.Exceptions));
                    tile.VectorDataState = TilePropertyState.Error;
                    return;
                }

                if (_cachedData.ContainsKey(tile))
                {
                    _cachedData[tile] = vectorTile;
                }
                else
                {
                    _cachedData.Add(tile, vectorTile);
                }

                // FIXME: we can make the request BEFORE getting a response from these!
                if (tile.HeightDataState == TilePropertyState.Loading ||
                    tile.RasterDataState == TilePropertyState.Loading)
                {
                    tile.OnHeightDataChanged += DataChangedHandler;
                    tile.OnRasterDataChanged += DataChangedHandler;
                }
                else
                {
                    CreateMeshes(tile);
                }
            });
        }