ArcGis Rest Services

Topics: WinForms Controls
Oct 30, 2015 at 1:38 PM
Hi, ArcGis has a public rest service which i'm trying to show maps with the help of SharpMap and BruTile.

http://services.arcgisonline.com/arcgis/rest/services/World_Terrain_Base/MapServer

I've tried below code;
  private static readonly double[] _unitsPerPixelArray =
        {
            156543.03392800014,
            78271.51696399994,
            39135.75848200009,
            19567.87924099992,
            9783.93962049996,
            4891.96981024998,
            2445.98490512499,
            1222.992452562495,
            611.4962262813797,
            305.74811314055756,
            152.87405657041106,
            76.43702828507324,
            38.21851414253662,
            19.10925707126831
        };

        private static ITileSchema CreateTileSchemaExample()
        {

            var schema = new TileSchema
            {
                Name = "Example",
                OriginX = -2.0037508342787E7,
                OriginY = 2.0037508342787E7,
                Axis = AxisDirection.InvertedY,
                Extent = new Extent(-2.0037507067161843E7, -1.9971868880408604E7, 2.0037507067161843E7, 1.997186888040863E7),
                Format = "JPEG",
                Srs = "EPSG:3857"
            };


            var i = 0;
            foreach (var unitsPerPixel in _unitsPerPixelArray)
            {
                var levelId = i++.ToString(CultureInfo.InvariantCulture);
                schema.Resolutions[levelId] = new Resolution
                {
                    Id = levelId,
                    UnitsPerPixel = unitsPerPixel,
                    TileHeight = 256,
                    TileWidth = 256,
                };
            }


            return schema;
        }

       private static SharpMap.Map CreateMap()
        {
            var map = new SharpMap.Map();

            var ts = CreateTileSchemaExample();


            var arcgissource = new ArcGisTileSource("http://services.arcgisonline.com/arcgis/rest/services/World_Terrain_Base/MapServer", ts);
            var tileLayer = new TileLayer(arcgissource, "World_Terrain_Base", Color.AliceBlue, true);
            map.Layers.Clear();
            map.BackgroundLayer.Add(tileLayer);
            map.Layers.Add(tileLayer);
            map.ZoomToExtents();
            return map;
        }
I'm using this map object returned from CreateMap function but i can't get any tiles.
I've tried to find out problem but couldn't find any.
Is there any working example of using ArcgisTileSource?