Example #1
0
        protected virtual void UpdateTiles(bool clearTiles)
        {
            if (Tiles.Count > 0)
            {
                TileImageLoader.CancelLoadTiles(this);
            }

            if (clearTiles)
            {
                Tiles.Clear();
            }

            SelectTiles();

            Children.Clear();

            if (Tiles.Count > 0)
            {
                foreach (var tile in Tiles)
                {
                    Children.Add(tile.Image);
                }

                var pendingTiles = Tiles.Where(t => t.Pending);

                if (LoadTilesDescending)
                {
                    pendingTiles = pendingTiles.OrderByDescending(t => t.ZoomLevel); // higher zoom levels first
                }

                TileImageLoader.BeginLoadTiles(this, pendingTiles);
            }
        }
Example #2
0
        private void UpdateTiles(WmtsTileMatrixSet tileMatrixSet)
        {
            var tiles = new List <Tile>();

            foreach (var layer in ChildLayers)
            {
                layer.UpdateTiles();
                tiles.AddRange(layer.Tiles);
            }

            var tileSource = TileSource as WmtsTileSource;
            var sourceName = SourceName;

            if (tileSource != null && tileMatrixSet != null)
            {
                tileSource.TileMatrixSet = tileMatrixSet;

                if (sourceName != null)
                {
                    sourceName += "/" + tileMatrixSet.Identifier
                                  .Replace(':', '_')
                                  .Replace(';', '_')
                                  .Replace(',', '_')
                                  .Replace('/', '_')
                                  .Replace('\\', '_');
                }
            }

            TileImageLoader.LoadTilesAsync(tiles, tileSource, sourceName);
        }
        private void UpdateTiles(WmtsTileMatrixSet tileMatrixSet)
        {
            var tiles = new List <Tile>();

            foreach (var layer in Children.Cast <WmtsTileMatrixLayer>())
            {
                layer.UpdateTiles();

                tiles.AddRange(layer.Tiles);
            }

            var tileSource = TileSource as WmtsTileSource;
            var sourceName = SourceName;

            if (tileSource != null && tileMatrixSet != null)
            {
                tileSource.TileMatrixSet = tileMatrixSet;

                if (sourceName != null)
                {
                    sourceName += "/" + tileMatrixSet.Identifier;
                }
            }

            TileImageLoader.LoadTilesAsync(tiles, TileSource, sourceName);
        }
Example #4
0
        protected virtual void UpdateTiles(bool clearTiles)
        {
            if (Tiles.Count > 0)
            {
                TileImageLoader.CancelLoadTiles(this);
            }

            if (clearTiles)
            {
                Tiles.Clear();
            }

            SelectTiles();

            Children.Clear();

            if (Tiles.Count > 0)
            {
                foreach (var tile in Tiles)
                {
                    Children.Add(tile.Image);
                }

                TileImageLoader.BeginLoadTiles(this, Tiles.Where(t => t.Pending).OrderByDescending(t => t.ZoomLevel));
            }
        }
        private void UpdateTiles()
        {
            var newTiles = new List <Tile>();

            if (parentMap != null && TileGrid != null && TileSource != null)
            {
                var maxZoomLevel = Math.Min(TileGrid.ZoomLevel, MaxZoomLevel);
                var minZoomLevel = MinZoomLevel;

                if (minZoomLevel < maxZoomLevel && parentMap.MapLayer != this)
                {
                    minZoomLevel = maxZoomLevel; // do not load lower level tiles if this is note a "base" layer
                }

                for (var z = minZoomLevel; z <= maxZoomLevel; z++)
                {
                    var tileSize = 1 << (TileGrid.ZoomLevel - z);
                    var x1       = (int)Math.Floor((double)TileGrid.XMin / tileSize); // may be negative
                    var x2       = TileGrid.XMax / tileSize;
                    var y1       = Math.Max(TileGrid.YMin / tileSize, 0);
                    var y2       = Math.Min(TileGrid.YMax / tileSize, (1 << z) - 1);

                    for (var y = y1; y <= y2; y++)
                    {
                        for (var x = x1; x <= x2; x++)
                        {
                            var tile = Tiles.FirstOrDefault(t => t.ZoomLevel == z && t.X == x && t.Y == y);

                            if (tile == null)
                            {
                                tile = new Tile(z, x, y);

                                var equivalentTile = Tiles.FirstOrDefault(
                                    t => t.ZoomLevel == z && t.XIndex == tile.XIndex && t.Y == y && t.Image.Source != null);

                                if (equivalentTile != null)
                                {
                                    tile.SetImage(equivalentTile.Image.Source, false); // no fade-in animation
                                }
                            }

                            newTiles.Add(tile);
                        }
                    }
                }
            }

            Tiles = newTiles;

            Children.Clear();

            foreach (var tile in Tiles)
            {
                Children.Add(tile.Image);
            }

            TileImageLoader.LoadTilesAsync(this);
        }
Example #6
0
        private void UpdateTiles()
        {
            var newTiles = new List <Tile>();

            if (parentMap != null && TileGrid != null && TileSource != null)
            {
                var maxZoomLevel = Math.Min(TileGrid.ZoomLevel, MaxZoomLevel);
                var minZoomLevel = parentMap.MapLayer == this ? MinZoomLevel : maxZoomLevel; // load background tiles only if this is the base layer

                for (var z = minZoomLevel; z <= maxZoomLevel; z++)
                {
                    var tileSize = 1 << (TileGrid.ZoomLevel - z);
                    var x1       = (int)Math.Floor((double)TileGrid.XMin / tileSize); // may be negative
                    var x2       = TileGrid.XMax / tileSize;
                    var y1       = Math.Max(TileGrid.YMin / tileSize, 0);
                    var y2       = Math.Min(TileGrid.YMax / tileSize, (1 << z) - 1);

                    for (var y = y1; y <= y2; y++)
                    {
                        for (var x = x1; x <= x2; x++)
                        {
                            var tile = Tiles.FirstOrDefault(t => t.ZoomLevel == z && t.X == x && t.Y == y);

                            if (tile == null)
                            {
                                tile = new Tile(z, x, y);

                                var equivalentTile = Tiles.FirstOrDefault(
                                    t => t.ZoomLevel == z && t.XIndex == tile.XIndex && t.Y == y && t.Image.Source != null);

                                if (equivalentTile != null)
                                {
                                    tile.SetImage(equivalentTile.Image.Source, false); // do not animate to avoid flicker when crossing 180° longitude
                                }
                            }

                            newTiles.Add(tile);
                        }
                    }
                }
            }

            Tiles = newTiles;

            Children.Clear();

            foreach (var tile in Tiles)
            {
                Children.Add(tile.Image);
            }

            var task = TileImageLoader.LoadTilesAsync(this);
        }
        private void UpdateTiles()
        {
            var newTiles = new List <Tile>();

            if (ParentMap != null && TileMatrix != null && TileSource != null)
            {
                var maxZoomLevel = Math.Min(TileMatrix.ZoomLevel, MaxZoomLevel);

                if (maxZoomLevel >= MinZoomLevel)
                {
                    var minZoomLevel = maxZoomLevel;

                    if (this == ParentMap.MapLayer) // load background tiles
                    {
                        minZoomLevel = Math.Max(TileMatrix.ZoomLevel - MaxBackgroundLevels, MinZoomLevel);
                    }

                    for (var z = minZoomLevel; z <= maxZoomLevel; z++)
                    {
                        var tileSize = 1 << (TileMatrix.ZoomLevel - z);
                        var x1       = (int)Math.Floor((double)TileMatrix.XMin / tileSize); // may be negative
                        var x2       = TileMatrix.XMax / tileSize;
                        var y1       = Math.Max(TileMatrix.YMin / tileSize, 0);
                        var y2       = Math.Min(TileMatrix.YMax / tileSize, (1 << z) - 1);

                        for (var y = y1; y <= y2; y++)
                        {
                            for (var x = x1; x <= x2; x++)
                            {
                                var tile = Tiles.FirstOrDefault(t => t.ZoomLevel == z && t.X == x && t.Y == y);

                                if (tile == null)
                                {
                                    tile = new Tile(z, x, y);

                                    var equivalentTile = Tiles.FirstOrDefault(
                                        t => t.ZoomLevel == z && t.XIndex == tile.XIndex && t.Y == y && t.Image.Source != null);

                                    if (equivalentTile != null)
                                    {
                                        tile.SetImage(equivalentTile.Image.Source, false); // no fade-in animation
                                    }
                                }

                                newTiles.Add(tile);
                            }
                        }
                    }
                }
            }

            Tiles = newTiles;

            Children.Clear();

            foreach (var tile in Tiles)
            {
                Children.Add(tile.Image);
            }

            TileImageLoader.LoadTilesAsync(Tiles, TileSource, SourceName);
        }
Example #8
0
 protected virtual void LoadTiles(IEnumerable <Tile> tiles, string cacheName)
 {
     TileImageLoader.LoadTiles(tiles, TileSource, cacheName);
 }
Example #9
0
 public GoogleMapsTileLayer(TileImageLoader tileImageLoader)
     : base(tileImageLoader)
 {
     tileImageLoader.HttpUserAgent = "Mozilla/5.0";
 }
Example #10
0
 public UCSMapTilesLayer(TileImageLoader tileImageLoader)
     : base(tileImageLoader)
 {
     tileImageLoader.HttpUserAgent = "Mozilla/5.0";
 }