require(["esri/layers/TiledMapServiceLayer"], function () {

dojo.declare("com.StrongIt.Map.Layers.LayerTianditu", esri.layers.TiledMapServiceLayer, {
        _mapStyle: "",
        constructor: function (mapStyle, startLevel, endLevel) {
            this._mapStyle = mapStyle;
            this.spatialReference = new esri.SpatialReference({
                wkid: 4326
            });
            this.initialExtent = new esri.geometry.Extent(73.5, 4, 135, 53.5, this.spatialReference);
            this.fullExtent = new esri.geometry.Extent(-180.0, -90.0, 180.0, 90.0, this.spatialReference);
            this.tileInfo = new esri.layers.TileInfo({
                "dpi": "90.71428571427429",
                "format": "image/png",
                "compressionQuality": 0,
                "rows": 256,
                "cols": 256,
                "compressionQuality": 0,
                "origin": {
                    "x": -180,
                    "y": 90
                },
                "spatialReference": {
                    "wkid": 4326
                },
                "lods": this._getLods(startLevel, endLevel)
            });

this.loaded = true;
            this.onLoad(this);
        },

getTileUrl: function (level, row, col) {
                var serviceNum = col % 8;
                var mapInfo = this._getMapInfo();
                return "http://t"
                    + serviceNum
                    + ".tianditu.com/DataServer?T=" + mapInfo.mapName + "&" +
                    "X=" + col + "&" +
                    "Y=" + row + "&" +
                    "L=" + level;
        },

_getLods: function (startLevel, endLevel) {
            var lods = [];

var minScale = 590995186.1175;
            var maxResolution = 1.40625;
            
            var tempScale = minScale;
            var tempResolution = maxResolution;
            for (var i = 0; i <= endLevel; i++) {
                
                var lod = {
                    "level": i,
                    "resolution": tempResolution,
                    "scale": tempScale
                }
                if (i >= startLevel) {
                    lods.push(lod);
                }

tempScale = tempScale / 2;
                tempResolution = tempResolution / 2;
            }

return lods;
        },

_getMapInfo: function () {
            var result = {
                mapName: "",
                layerId: "",
                tileMatrixSetId: ""
            };
            if(this._mapStyle == "ImageBaseMap") {
                // 获取影像(底图)
                result.mapName = "img_c";
                result.layerId = "img";
                result.tileMatrixSetId = "c";
            } else if(this._mapStyle == "ImageCNNote") {
                // 获取影像(中文注记)
                result.mapName = "cia_c";
                result.layerId = "cia";
                result.tileMatrixSetId = "c";
            } else if(this._mapStyle == "ImageENNote") {
                // 获取影像(英文注记)
                result.mapName = "eia_c";
                result.layerId = "eia";
                result.tileMatrixSetId = "c";
            } else if(this._mapStyle == "TerrainBaseMap") {
                // 获取地形图(底图)
                result.mapName = "ter_c";
                result.layerId = "ter";
                result.tileMatrixSetId = "c";
            } else if(this._mapStyle == "TerrainCNNote") {
                // 获取地形图(中文注记)
                result.mapName = "cta_c";
                result.layerId = "cta";
                result.tileMatrixSetId = "c";
            } else if(this._mapStyle == "TerrainENNote") {
                // 获取地形图(英文注记)
            } else if(this._mapStyle == "VectorBaseMap") {
                // 获取地图(底图)
                result.mapName = "vec_c";
                result.layerId = "vec";
                result.tileMatrixSetId = "c";
            } else if(this._mapStyle == "VectorCNNote") {
                // 获取地图(中文注记)
                result.mapName = "cva_c";
                result.layerId = "cva";
                result.tileMatrixSetId = "c";
            } else if(this._mapStyle == "VectorENNote") {
                // 获取地图(英文注记)
                result.mapName = "eva_c";
                result.layerId = "eva";
                result.tileMatrixSetId = "c";
            }

return result;
        }
    });

});

重写ArcGIS的TiledMapServiceLayer调用天地图瓦片的更多相关文章

  1. 重写ArcGIS的TiledMapServiceLayer呼叫世界地图图块

    require(["esri/layers/TiledMapServiceLayer"], function () {     dojo.declare("com.Str ...

  2. Arcgis for js载入天地图

    综述:本节讲述的是用Arcgis for js载入天地图的切片资源. 天地图的切片地图能够通过esri.layers.TiledMapServiceLayer来载入.在此将之进行了一定的封装,例如以下 ...

  3. OpenLayer3调用天地图示例

    最近,工作中有需要用Openlayer3脚本库调用天地图的wmts服务接口,由于这两个都是刚开始接触,所以是摸着石头过河,遇到了地图显示不了的问题,虽然官网http://www.zjditu.cn/r ...

  4. Leaflet 调用百度瓦片地图服务

    在使用 leaflet 调用第三方瓦片地图服务的项目,主要谷歌地图.高德地图.百度地图和 OSM 地图,与其他三种地图对比,百度地图的瓦片组织方式是不同的.百度从中心点经纬度(0,0)度开始计算瓦片, ...

  5. 如何使用借助python完成 ARCGIS工具箱的调用

    上个月使用python调用arcgis工具箱完成了火点txt文件转shp文件的小功能, 感觉很不错, 写下这篇博客希望对大家有所帮助. 1.环境介绍: 系统: win8.1(64位) arcgis:d ...

  6. arcgis js之调用wms服务

    arcgis js之调用wms服务 定义: export const tdtlayer = async () => { let WMSLayer = await arcgisPackage.WM ...

  7. 2019年以后ArcGIS 调用天地图的资源URL

    2019年1月1日起,天地图做出如下变更,导致直接在Arcgis/ArcMap中添加WMTS服务不能用了. 国家天地图解释的很清楚,注册个人用户就可以了. 原有调用方式不变,只要在URL 后添加“&a ...

  8. 重写 final关键字 多态调用子类特有的属性及行为(向上向下转型)

    1.override 重写:在继承中,子类与父类方法名相同,参数列表相同,的方法叫重写,与返回值有关;  主要应用于系统升级. 2.final 关键字: 可修饰:1.类-->被修饰后该类不能被继 ...

  9. 一个对象toString()方法如果没有被重写,那么默认调用它的父类Object的toString()方法,而Object的toString()方法是打印该对象的hashCode,一般hashCode就是此对象的内存地址

    昨天因为要从JFrame控件获取密码,注意到一个问题,那就是用toString方法得到的不一定是你想要的,如下: jPasswordField是JFrame中的密码输入框,如果用下面的方法是得不到密码 ...

随机推荐

  1. 【SD系列】SAP SD模块-销售收入科目的配置

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[SD系列]SAP SD模块-销售收入科目的配置 ...

  2. apt-get updete以及apt-get upgrade的区别

    You should first run update, then upgrade. Neither of them automatically runs the other. apt-get upd ...

  3. hashCode -哈希值,Object中的方法,常根据实际情况重写

    package cn.learn.collection; import cn.learn.basic.Phone; /* 哈希值:是一个十进制的整数,由系统随机给出(就是对象的地址值),是一个逻辑地址 ...

  4. MySQL-第六篇DML语句

    1.DML主要操作数据表里的数据,主要完成3个任务: 1>insert:插入数据.格式:insert into ... 2>delete:删除数据.格式:delete from ... 3 ...

  5. java_第一年_JavaWeb(9)

    JavaBean是一个遵循某种特定写法的Java类,有以下特点: 必需具有一个无参的构造函数 属性必需私有化 私有化的属性必需通过public类型的方法暴露给其它程序,其方法命名也有一定的规范 范例: ...

  6. LOJ 2234/BZOJ 3629 聪明的燕姿(数论+DFS)

    题面 传送门 分析 看到约数之和,我们首先想到约数和公式 若$ x=\prod_{i=1}^{n}p_i^{k_i} \(,则x的约数和为\) \prod_{i=1}^{n} \sum_{j=0}^{ ...

  7. Codeforces Round #521 (Div. 3) E. Thematic Contests(思维)

    Codeforces Round #521 (Div. 3)  E. Thematic Contests 题目传送门 题意: 现在有n个题目,每种题目有自己的类型要举办一次考试,考试的原则是每天只有一 ...

  8. BZOJ1672 Cleaning Shifts 清理牛棚

    传送门 显然可以考虑 $dp$ 设 $f[i]$ 表示当前到了时间 $i$,从初始到 $i$ 的时间都安排好打扫了 把所有牛按照区间 $l,r$ 双关键字排序 这样枚举到一头牛 $x$ 时,在 $x. ...

  9. Codeforces 208E. Blood Cousins

    传送门 题目大意: 小C喜欢研究族谱,这一天小C拿到了一整张族谱. 小C先要定义一下k-祖先. x的1-祖先指的是x的父亲 x的k-祖先指的是x的(k-1)-祖先的父亲 小C接下来要定义k-兄弟 x的 ...

  10. Css3-颜色 color

    一.颜色 RGBA RGB是一种色彩标准,是由红(R).绿(G).蓝(B)的变化以及相互叠加来得到各式各样的颜色.RGBA是在RGB的基础上增加了控制alpha透明度的参数. 语法:color:rgb ...