微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

silverlight+newmap

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using ESRI.ArcGIS.Client;
using ESRI.ArcGIS.Client.Geometry;
using System.Text;
using ESRI.ArcGIS.Client.Toolkit.DataSources;

namespace sdhbgis.Dal
{
    public class WMTSTileNewMap : TiledMapServiceLayer
    {
        // WMTS 调用地址
        private string _url = "http://222.1.1.1/newmap/ogc/TIANDITU/DZVectorAnnoMap/wmts/";
        private string _layer = "DZVectorMap";

        public string Layer1
        {
            get { return _layer; }
            set { _layer = value; }
        }
        // private Extent _fullExtent = new Extent(115.755718613879,36.4084387897639,117.600377956462,38.0106631803602,_spatialReference);
        // Properties
        public string Url
        {
            get
            {
                return this._url;
            }
            set
            {
                this._url = value;
            }
        }


        public override void Initialize()
        {
            ESRI.ArcGIS.Client.Geometry.Envelope envelope = new ESRI.ArcGIS.Client.Geometry.Envelope(115.755718613879,38.0106631803602);
            envelope.SpatialReference = new SpatialReference(4490);
            this.FullExtent = envelope;
            base.SpatialReference = new SpatialReference(4490);
            Lod[] lodArray = new Lod[12];
            Lod lod = new Lod();
            Lod lod0 = new Lod();
            lod0.Resolution = 0.00274658203125;
            lodArray[0] = lod0;
            Lod lod1 = new Lod();
            lod1.Resolution = 0.001373291015625;
            lodArray[1] = lod1;
            Lod lod2 = new Lod();
            lod2.Resolution = 0.0006866455078125;
            lodArray[2] = lod2;
            Lod lod3 = new Lod();
            lod3.Resolution = 0.00034332275390625;
            lodArray[3] = lod3;
            Lod lod4 = new Lod();
            lod4.Resolution = 0.000171661376953125;
            lodArray[4] = lod4;
            Lod lod5 = new Lod();
            lod5.Resolution = 0.0000858306884765625;
            lodArray[5] = lod5;
            Lod lod6 = new Lod();
            lod6.Resolution = 0.00004291534423828125;
            lodArray[6] = lod6;
            Lod lod7 = new Lod();
            lod7.Resolution = 0.000021457672119140625;
            lodArray[7] = lod7;
            Lod lod8 = new Lod();
            lod8.Resolution = 0.0000107288360595703125;
            lodArray[8] = lod8;
            Lod lod9 = new Lod();
            lod9.Resolution = 0.00000536441802978515625;
            lodArray[9] = lod9;
            Lod lod10 = new Lod();
            lod10.Resolution = 0.000002682209014892578125;
            lodArray[10] = lod10;
            Lod lod11 = new Lod();
            lod11.Resolution = 0.0000013411045074462890625;
            lodArray[11] = lod11;


            TileInfo info = new TileInfo();
            // info.Height = 256;
            //info.Width = 256;
            // MapPoint point = new MapPoint(-180.0,90.0);
            //// point.SpatialReference = new SpatialReference(4610);
            //  info.Origin = point;
            info.SpatialReference = new SpatialReference(4490);
            info.Height = 256;
            info.Width = 256;
            // info.format = "image/png";
            info.Origin = new MapPoint(-180,90);
            info.Lods = lodArray;
            base.TileInfo = info;
            base.Initialize();
        }


        // 重写方法
        public override string GetTileUrl(int level,int row,int col)
        {
            String url = Url
            + "?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile" + "&LAYER=" + Layer1 + "&STYLE=Default" + "&FORMAT=image/png" + "&TILEMATRIXSET=TileMatrixSet_0"
            + "&TILEMATRIX=" + level
            + "&TILEROW=" + row
            + "&TILECOL=" + col;
            return url;
        }

    } }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐