arcgis api for javascript 加载地图--(转)
//google地形图,自定义部分 //#region google地形图 继承esri.layers.TiledMapServiceLayer类,生成新类MapABCLayer function initLayer() { //QQ地图 继承esri.layers.TiledMapServiceLayer类,生成新类QQLayer //天地图 继承esri.layers.TiledMapServiceLayer类,生成新类TDTLayer 和 TDTAnnoLayer //mapABC地图 继承esri.layers.TiledMapServiceLayer类,生成新类MapABCLayer //google地形图 继承esri.layers.TiledMapServiceLayer类,生成新类MapABCLayer //希望再弄个百度地图
//QQ地图 继承esri.layers.TiledMapServiceLayer类,生成新类QQLayer
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
//QQ地图 继承esri.layers.TiledMapServiceLayer类,生成新类QQLayer dojo.declare("QQLayer", esri.layers.TiledMapServiceLayer, { _subDomains: new Array("p0", "p1", "p2", "p3"), scope: new Array(0, 0, 0, 0, 0, 3, 0, 3, 0, 3, 0, 3, 0, 7, 0, 7, 0, 15, 0, 15, 0, 31, 0, 31, 0, 63, 4, 59, 0, 127, 12, 115, 0, 225, 28, 227, 356, 455, 150, 259, 720, 899, 320, 469, 1440, 1799, 650, 929, 2880, 3589, 1200, 2069, 5760, 7179, 2550, 3709, 11520, 14349, 5100, 7999, 23060, 28689, 10710, 15429, 46120, 57369, 20290, 29849, 89990, 124729, 41430, 60689, 184228, 229827, 84169, 128886), constructor: function () { this.spatialReference = new esri.SpatialReference({ wkid: 102113 }); this.initialExtent = (this.fullExtent = new esri.geometry.Extent(-20037508.342787, -20037508.342787, 20037508.342787, 20037508.342787, this.spatialReference)); this.tileInfo = new esri.layers.TileInfo({ "rows": 256, "cols": 256, "compressionQuality": 0, "origin": { "x": -20037508.342787, "y": 20037508.342787 }, "spatialReference": { "wkid": 102113 }, "lods": [ { "level": 0, "resolution": 156543.033928, "scale": 591657527.591555 }, { "level": 1, "resolution": 78271.5169639999, "scale": 295828763.795777 }, { "level": 2, "resolution": 39135.7584820001, "scale": 147914381.897889 }, { "level": 3, "resolution": 19567.8792409999, "scale": 73957190.948944 }, { "level": 4, "resolution": 9783.93962049996, "scale": 36978595.474472 }, { "level": 5, "resolution": 4891.96981024998, "scale": 18489297.737236 }, { "level": 6, "resolution": 2445.98490512499, "scale": 9244648.868618 }, { "level": 7, "resolution": 1222.99245256249, "scale": 4622324.434309 }, { "level": 8, "resolution": 611.49622628138, "scale": 2311162.217155 }, { "level": 9, "resolution": 305.748113140558, "scale": 1155581.108577 }, { "level": 10, "resolution": 152.874056570411, "scale": 577790.554289 }, { "level": 11, "resolution": 76.4370282850732, "scale": 288895.277144 }, { "level": 12, "resolution": 38.2185141425366, "scale": 144447.638572 }, { "level": 13, "resolution": 19.1092570712683, "scale": 72223.819286 }, { "level": 14, "resolution": 9.55462853563415, "scale": 36111.909643 }, { "level": 15, "resolution": 4.77731426794937, "scale": 18055.954822 }, { "level": 16, "resolution": 2.38865713397468, "scale": 9027.977411 }, { "level": 17, "resolution": 1.19432856685505, "scale": 4513.988705 }, { "level": 18, "resolution": 0.597164283559817, "scale": 2256.994353 }, { "level": 19, "resolution": 0.298582141647617, "scale": 1128.497176 } ] }); this.loaded = true; this.onLoad(this); }, getTileUrl: function (level, row, col) { var subdomain = this._subDomains[(level + col + row) % this._subDomains.length]; var f = level * 4; var i = this.scope[f++]; var j = this.scope[f++]; var l = this.scope[f++]; var scope = this.scope[f]; var tileNo = ""; if (col >= i && col <= j && row >= l && row <= scope) { row = Math.pow(2, level) - 1 - row; tileNo = level + "/" + Math.floor(col / 16) + "/" + Math.floor(row / 16) + "/" + col + "_" + row + ".png"; } return "http://" + subdomain + ".map.qq.com/maptiles/" + tileNo; } });
//天地图 继承esri.layers.TiledMapServiceLayer类,生成新类TDTLayer 和 TDTAnnoLayer
//新类TDTLayer ——第一部分
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
//天地图 继承esri.layers.TiledMapServiceLayer类,生成新类TDTLayer 和 TDTAnnoLayer dojo.declare("TDTLayer", esri.layers.TiledMapServiceLayer, { constructor: function () { this.spatialReference = new esri.SpatialReference({ wkid: 4326 }); this.initialExtent = (this.fullExtent = new esri.geometry.Extent(-180.0, -90.0, 180.0, 90.0, this.spatialReference)); this.tileInfo = new esri.layers.TileInfo({ "rows": 256, "cols": 256, "compressionQuality": 0, "origin": { "x": -180, "y": 90 }, "spatialReference": { "wkid": 4326 }, "lods": [ { "level": 0, "resolution": 0.703125, "scale": 295497593.05875003 }, { "level": 1, "resolution": 0.3515625, "scale": 147748796.52937502 }, { "level": 2, "resolution": 0.17578125, "scale": 73874398.264687508 }, { "level": 3, "resolution": 0.087890625, "scale": 36937199.132343754 }, { "level": 4, "resolution": 0.0439453125, "scale": 18468599.566171877 }, { "level": 5, "resolution": 0.02197265625, "scale": 9234299.7830859385 }, { "level": 6, "resolution": 0.010986328125, "scale": 4617149.8915429693 }, { "level": 7, "resolution": 0.0054931640625, "scale": 2308574.9457714846 }, { "level": 8, "resolution": 0.00274658203125, "scale": 1154287.4728857423 }, { "level": 9, "resolution": 0.001373291015625, "scale": 577143.73644287116 }, { "level": 10, "resolution": 0.0006866455078125, "scale": 288571.86822143558 }, { "level": 11, "resolution": 0.00034332275390625, "scale": 144285.93411071779 }, { "level": 12, "resolution": 0.000171661376953125, "scale": 72142.967055358895 }, { "level": 13, "resolution": 8.58306884765625e-005, "scale": 36071.483527679447 }, { "level": 14, "resolution": 4.291534423828125e-005, "scale": 18035.741763839724 }, { "level": 15, "resolution": 2.1457672119140625e-005, "scale": 9017.8708819198619 }, { "level": 16, "resolution": 1.0728836059570313e-005, "scale": 4508.9354409599309 }, { "level": 17, "resolution": 5.3644180297851563e-006, "scale": 2254.4677204799655 } ] }); this.loaded = true; this.onLoad(this); }, getTileUrl: function (level, row, col) { var levelMap = ""; if (level < 10) { levelMap = "A0512_EMap"; } else if (level < 12) { levelMap = "B0627_EMap1112"; } else if (level < 17) { levelMap = "siwei0608"; } return "http://tile0.tianditu.com/DataServer?T=" + levelMap + "&" + "X=" + col + "&" + "Y=" + row + "&" + "L=" + (level * 1 + 1); } });
//天地图 继承esri.layers.TiledMapServiceLayer类,生成新类TDTLayer 和 TDTAnnoLayer
//新类TDTAnnoLayer——第二部分
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
dojo.declare("TDTAnnoLayer", esri.layers.TiledMapServiceLayer, { constructor: function () { this.spatialReference = new esri.SpatialReference({ wkid: 4326 }); this.initialExtent = (this.fullExtent = new esri.geometry.Extent(-180.0, -90.0, 180.0, 90.0, this.spatialReference)); this.tileInfo = new esri.layers.TileInfo({ "rows": 256, "cols": 256, "compressionQuality": 0, "origin": { "x": -180, "y": 90 }, "spatialReference": { "wkid": 4326 }, "lods": [ { "level": 0, "resolution": 0.703125, "scale": 295497593.05875003 }, { "level": 1, "resolution": 0.3515625, "scale": 147748796.52937502 }, { "level": 2, "resolution": 0.17578125, "scale": 73874398.264687508 }, { "level": 3, "resolution": 0.087890625, "scale": 36937199.132343754 }, { "level": 4, "resolution": 0.0439453125, "scale": 18468599.566171877 }, { "level": 5, "resolution": 0.02197265625, "scale": 9234299.7830859385 }, { "level": 6, "resolution": 0.010986328125, "scale": 4617149.8915429693 }, { "level": 7, "resolution": 0.0054931640625, "scale": 2308574.9457714846 }, { "level": 8, "resolution": 0.00274658203125, "scale": 1154287.4728857423 }, { "level": 9, "resolution": 0.001373291015625, "scale": 577143.73644287116 }, { "level": 10, "resolution": 0.0006866455078125, "scale": 288571.86822143558 }, { "level": 11, "resolution": 0.00034332275390625, "scale": 144285.93411071779 }, { "level": 12, "resolution": 0.000171661376953125, "scale": 72142.967055358895 }, { "level": 13, "resolution": 8.58306884765625e-005, "scale": 36071.483527679447 }, { "level": 14, "resolution": 4.291534423828125e-005, "scale": 18035.741763839724 }, { "level": 15, "resolution": 2.1457672119140625e-005, "scale": 9017.8708819198619 }, { "level": 16, "resolution": 1.0728836059570313e-005, "scale": 4508.9354409599309 }, { "level": 17, "resolution": 5.3644180297851563e-006, "scale": 2254.4677204799655 } ] }); this.loaded = true; this.onLoad(this); }, getTileUrl: function (level, row, col) { return "http://tile0.tianditu.com/DataServer?T=AB0512_Anno&" + "X=" + col + "&" + "Y=" + row + "&" + "L=" + (level * 1 + 1); } });
//mapABC地图 继承esri.layers.TiledMapServiceLayer类,生成新类MapABCLayer
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
//mapABC地图 继承esri.layers.TiledMapServiceLayer类,生成新类MapABCLayer dojo.declare("MapABCLayer", esri.layers.TiledMapServiceLayer, { _subDomains: new Array("emap0", "emap1", "emap2", "emap3"), constructor: function () { this.spatialReference = new esri.SpatialReference({ wkid: 102113 }); this.initialExtent = (this.fullExtent = new esri.geometry.Extent(-20037508.342787, -20037508.342787, 20037508.342787, 20037508.342787, this.spatialReference)); this.tileInfo = new esri.layers.TileInfo({ "rows": 256, "cols": 256, "compressionQuality": 0, "origin": { "x": -20037508.342787, "y": 20037508.342787 }, "spatialReference": { "wkid": 102113 }, "lods": [ { "level": 0, "resolution": 156543.033928, "scale": 591657527.591555 }, { "level": 1, "resolution": 78271.5169639999, "scale": 295828763.795777 }, { "level": 2, "resolution": 39135.7584820001, "scale": 147914381.897889 }, { "level": 3, "resolution": 19567.8792409999, "scale": 73957190.948944 }, { "level": 4, "resolution": 9783.93962049996, "scale": 36978595.474472 }, { "level": 5, "resolution": 4891.96981024998, "scale": 18489297.737236 }, { "level": 6, "resolution": 2445.98490512499, "scale": 9244648.868618 }, { "level": 7, "resolution": 1222.99245256249, "scale": 4622324.434309 }, { "level": 8, "resolution": 611.49622628138, "scale": 2311162.217155 }, { "level": 9, "resolution": 305.748113140558, "scale": 1155581.108577 }, { "level": 10, "resolution": 152.874056570411, "scale": 577790.554289 }, { "level": 11, "resolution": 76.4370282850732, "scale": 288895.277144 }, { "level": 12, "resolution": 38.2185141425366, "scale": 144447.638572 }, { "level": 13, "resolution": 19.1092570712683, "scale": 72223.819286 }, { "level": 14, "resolution": 9.55462853563415, "scale": 36111.909643 }, { "level": 15, "resolution": 4.77731426794937, "scale": 18055.954822 }, { "level": 16, "resolution": 2.38865713397468, "scale": 9027.977411 }, { "level": 17, "resolution": 1.19432856685505, "scale": 4513.988705 }, { "level": 18, "resolution": 0.597164283559817, "scale": 2256.994353 }, { "level": 19, "resolution": 0.298582141647617, "scale": 1128.497176 } ] }); this.loaded = true; this.onLoad(this); }, getTileUrl: function (level, row, col) { var subdomain = this._subDomains[(level + col + row) % this._subDomains.length]; return "http://" + subdomain + ".is.autonavi.com/appmaptile?&z=" + level + "&x=" + col + "&y=" + row; } });
//google地形图 继承esri.layers.TiledMapServiceLayer类,生成新类MapABCLayer
dojo.declare("GoogleTopographicLayer",
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
//google地形图 继承esri.layers.TiledMapServiceLayer类,生成新类MapABCLayer dojo.declare("GoogleTopographicLayer", esri.layers.TiledMapServiceLayer, { constructor: function () { this.spatialReference = new esri.SpatialReference({ wkid: 102113 }); this.initialExtent = (this.fullExtent = new esri.geometry.Extent(-20037508.342787, -20037508.342787, 20037508.342787, 20037508.342787, this.spatialReference)); this.tileInfo = new esri.layers.TileInfo({ "rows": 256, "cols": 256, "compressionQuality": 0, "origin": { "x": -20037508.342787, "y": 20037508.342787 }, "spatialReference": { "wkid": 102113 }, "lods": [ { "level": 0, "resolution": 156543.033928, "scale": 591657527.591555 }, { "level": 1, "resolution": 78271.5169639999, "scale": 295828763.795777 }, { "level": 2, "resolution": 39135.7584820001, "scale": 147914381.897889 }, { "level": 3, "resolution": 19567.8792409999, "scale": 73957190.948944 }, { "level": 4, "resolution": 9783.93962049996, "scale": 36978595.474472 }, { "level": 5, "resolution": 4891.96981024998, "scale": 18489297.737236 }, { "level": 6, "resolution": 2445.98490512499, "scale": 9244648.868618 }, { "level": 7, "resolution": 1222.99245256249, "scale": 4622324.434309 }, { "level": 8, "resolution": 611.49622628138, "scale": 2311162.217155 }, { "level": 9, "resolution": 305.748113140558, "scale": 1155581.108577 }, { "level": 10, "resolution": 152.874056570411, "scale": 577790.554289 }, { "level": 11, "resolution": 76.4370282850732, "scale": 288895.277144 }, { "level": 12, "resolution": 38.2185141425366, "scale": 144447.638572 }, { "level": 13, "resolution": 19.1092570712683, "scale": 72223.819286 }, { "level": 14, "resolution": 9.55462853563415, "scale": 36111.909643 }, { "level": 15, "resolution": 4.77731426794937, "scale": 18055.954822 }, { "level": 16, "resolution": 2.38865713397468, "scale": 9027.977411 }, { "level": 17, "resolution": 1.19432856685505, "scale": 4513.988705 }, { "level": 18, "resolution": 0.597164283559817, "scale": 2256.994353 }, { "level": 19, "resolution": 0.298582141647617, "scale": 1128.497176 } ] }); this.loaded = true; this.onLoad(this); }, getTileUrl: function (level, row, col) { //return "http://" + "mt" + (col % 4) + ".google.cn/vt/v=w2.114&hl=zh-CN&gl=cn&x=" + col + "&y=" + row + "&z=" + level + "&s="; // var s:String = "Galileo".substring(0, ((3 * x + y) 8));.google.cn/vt/lyrs=t@129,r@195000000&hl=zh-CN&gl=CN&src=app&x= var s = "Galileo".substring(0, ((3 * col + row) % 8)); return "http://" + "mt" + (col % 4) + ".google.cn/vt/lyrs=t@129,r@195000000&hl=zh-CN&gl=CN&src=app&x=" + col + "&y=" + row + "&z=" + level + "&s=" + s; // http://mt2.google.cn/vt/imgtp=png32&lyrs=h@229000000&hl=zh-CN&gl=CN&src=app&x=48&y=27&z=6&s=Gal } });
作者:爱ai优酷
出处:http://www.cnblogs.com/aiyouku/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。