重写ArcGIS的TiledMapServiceLayer呼叫世界地图图块
2015-09-09 15:22
393 查看
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;
}
});
});
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;
}
});
});
相关文章推荐
- 安卓图表引擎AchartEngine
- Oracle的function
- 30-linux学习总结
- Android进阶之读取手机短信显示listview
- ubuntu 14.04 root
- PL/SQL破解方法,不需要密匙
- UISearchBar 背景 边框设置
- 软件编程网站收集
- vs2010+qt4编译出现error LNK2001: 无法解析的外部符号 "public: virtual struct QMetaObject等错误
- 关于jQuery版本不同而产生的问题、写法的记录
- 0909操作系统看法
- Currency Exchange
- UNIX环境中Real time, User time and Sys time
- [转载文章] 应用程序逻辑错误总结
- myBatis的SQL注入问题
- 欢迎使用CSDN-markdown编辑器
- 20150909—Win10系统80端口被System占用
- 挂载云硬盘后的分区、格式化与挂载
- (iPhone/iPad开发)在UIWebView中自定义菜单栏
- android开发,静音录制视频,在一般清晰度的前提下保证文件大小越小越好