Exemplo n.º 1
0
        public static MapRoute ToBingMapRoute(this GeoRoute route, int level)
        {
            MapRoute maproute = new MapRoute(level);

            foreach (PointLatLng pos in route)
            {
                maproute.Add(BingMapTileSystem.LatLngToPixelXY(pos, level));
            }
            return(maproute);
        }
Exemplo n.º 2
0
        public static GeoRoute BingMapToGeoRoute(this MapRoute route)
        {
            GeoRoute georoute = new GeoRoute();

            foreach (PointInt pos in route)
            {
                georoute.Add(BingMapTileSystem.PixelXYToLatLong(pos, route.Level));
            }
            return(georoute);
        }
Exemplo n.º 3
0
        private string MakeImageUrl(RawTile tile, string language)
        {
            string key = BingMapTileSystem.TileXYToQuadKey(tile.TileXY, tile.Level);

            switch (tile.Type)
            {
            case MapType.BingMap:
                return(string.Format("http://ecn.t{0}.tiles.virtualearth.net/tiles/r{1}.png?g={2}&mkt={3}{4}",
                                     GetServerNum(tile.TileXY, 4), key, VersionBingMaps, language, !string.IsNullOrEmpty(BingMapsClientToken) ? "&token=" + BingMapsClientToken : string.Empty));

            case MapType.BingSatellite:
                return(string.Format("http://ecn.t{0}.tiles.virtualearth.net/tiles/a{1}.jpeg?g={2}&mkt={3}{4}",
                                     GetServerNum(tile.TileXY, 4), key, VersionBingMaps, language, !string.IsNullOrEmpty(BingMapsClientToken) ? "&token=" + BingMapsClientToken : string.Empty));

            case MapType.BingHybrid:
                return(string.Format("http://ecn.t{0}.tiles.virtualearth.net/tiles/h{1}.jpeg?g={2}&mkt={3}{4}",
                                     GetServerNum(tile.TileXY, 4), key, VersionBingMaps, language, !string.IsNullOrEmpty(BingMapsClientToken) ? "&token=" + BingMapsClientToken : string.Empty));

            case MapType.BingMapChinese:
                return(string.Format("http://r2.tiles.ditu.live.com/tiles/r{0}.png?g=41", key));
            }
            return(null);
        }
Exemplo n.º 4
0
        public override void OnUpdateMap(MapArea viewarea)
        {
            Stopwatch watch             = Stopwatch.StartNew();
            PointInt  topleftTileXY     = BingMapTileSystem.PixelXYToTileXY(viewarea.Area.TopLeft);
            PointInt  bottomrightTileXY = BingMapTileSystem.PixelXYToTileXY(viewarea.Area.BottomRight);

            topleftTileXY.Offset(-2, -2);
            bottomrightTileXY.Offset(2, 2);
            if (topleftTileXY.X < 0)
            {
                topleftTileXY.X = 0;
            }
            if (topleftTileXY.Y < 0)
            {
                topleftTileXY.Y = 0;
            }
            int len = 1 << viewarea.Level;

            if (bottomrightTileXY.X >= len)
            {
                bottomrightTileXY.X = len - 1;
            }
            if (bottomrightTileXY.Y >= len)
            {
                bottomrightTileXY.Y = len - 1;
            }

            List <PointInt> pointlist = new List <PointInt>();

            for (int i = topleftTileXY.X; i <= bottomrightTileXY.X; i++)
            {
                for (int j = topleftTileXY.Y; j <= bottomrightTileXY.Y; j++)
                {
                    pointlist.Add(new PointInt(i, j));
                }
            }
            List <RawTile> toBeDel = new List <RawTile>();

            foreach (RawTile tile in tileViewDict.Keys)
            {
                if (tile.Level == viewarea.Level)
                {
                    pointlist.Remove(tile.TileXY);
                }
                RectInt tilerect = new RectInt(
                    (tile.TileXY.X - 1) * TileLength, (tile.TileXY.Y - 1) * TileLength, TileLength * 2, TileLength * 2);
                if (tile.Level != viewarea.Level)// || !tilerect.HasIntersectsWith(viewarea.Area))
                {
                    toBeDel.Add(tile);
                }
            }
            foreach (RawTile tile in toBeDel)
            {
                tileViewDict.Remove(tile);
            }

            foreach (PointInt p in pointlist)
            {
                RawTile tileKey = new RawTile(this.MapType, p, viewarea.Level);
                tileViewDict.Add(tileKey, null);
                tileLoadManager.LoadTileAsync(tileKey);
            }
            watch.Stop();
            //Debug.Write(" GetTiles: " + watch.Elapsed.TotalMilliseconds);
        }