ArcGIS API for JS 3.x 加载wmts格式天地图

require(["esri/map", "dojo/domReady!"], function (Map) {
        var map = new Map("map", {
            center: [120, 34.5],
            zoom: 8,
            //basemap: "topo"
        });
        declareVector();
        declareLabel();
        var vector = new VectorLayer();
        var label = new LabelLayer();
        map.addLayer(vector, 0);
        map.addLayer(label, 1);
    });
// 声明矢量图层
function declareVector() {
    declareMap("http://t5.tianditu.com/vec_c/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=vec&STYLE=default&TILEMATRIXSET=c&FORMAT=tiles", "VectorLayer");
}
// 声明矢量标注图层
function declareLabel() {
    declareMap("http://t0.tianditu.com/cva_c/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cva&STYLE=default&TILEMATRIXSET=c&FORMAT=tiles", "LabelLayer");
}
// 声明天地图
function declareMap(url, type) {
    dojo.declare(type, esri.layers.TiledMapServiceLayer, {
        constructor: function () {
            this.spatialReference = new esri.SpatialReference({ wkid: 4326 });
            this.initialExtent = (this.fullExtent = new esri.geometry.Extent(-180, -90, 180, 90, this.spatialReference));
            this.tileInfo = new esri.layers.TileInfo({
                "rows": 256,
                "cols": 256,
                "compressionQuality": 0,
                "origin": {
                    "x": -180,
                    "y": 90
                },
                "spatialReference": {
                    "wkid": 4326
                },
                "lods": [
                    { "level": 1, "resolution": 0.703125, "scale": 2.958293554545656E8 },
                    { "level": 2, "resolution": 0.3515625, "scale": 1.479146777272828E8 },
                    { "level": 3, "resolution": 0.17578125, "scale": 7.39573388636414E7 },
                    { "level": 4, "resolution": 0.087890625, "scale": 3.69786694318207E7 },
                    { "level": 5, "resolution": 0.0439453125, "scale": 1.848933471591035E7 },
                    { "level": 6, "resolution": 0.02197265625, "scale": 9244667.357955175 },
                    { "level": 7, "resolution": 0.010986328125, "scale": 4622333.678977588 },
                    { "level": 8, "resolution": 0.0054931640625, "scale": 2311166.839488794 },
                    { "level": 9, "resolution": 0.00274658203125, "scale": 1155583.419744397 },
                    { "level": 10, "resolution": 0.001373291015625, "scale": 577791.7098721985 },
                    { "level": 11, "resolution": 0.0006866455078125, "scale": 288895.85493609926 },
                    { "level": 12, "resolution": 0.00034332275390625, "scale": 144447.92746804963 },
                    { "level": 13, "resolution": 0.000171661376953125, "scale": 72223.96373402482 },
                    { "level": 14, "resolution": 8.58306884765625e-005, "scale": 36111.98186701241 },
                    { "level": 15, "resolution": 4.291534423828125e-005, "scale": 18055.990933506204 },
                    { "level": 16, "resolution": 2.1457672119140625e-005, "scale": 9027.995466753102 },
                    { "level": 17, "resolution": 1.0728836059570313e-005, "scale": 4513.997733376551 },
                    { "level": 18, "resolution": 5.3644180297851563e-006, "scale": 2256.998866688275 },
                    { "level": 19, "resolution": 0.000002682209014892578, "scale": 1128.4994333441375 }
                ]
            });
            this.loaded = true;
            this.onLoad(this);
        },
        getTileUrl: function (level, row, col) {
            return url + "&TILEMATRIX=" + level + "&TILEROW=" + row + "&TILECOL=" + col;
            //return "http://t" + col % 8 + ".tianditu.com/img_c/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=c&TILEMATRIX=" + level + "&TILEROW=" + row + "&TILECOL=" + col + "&FORMAT=tiles";
        }
    });
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值