您的位置:首页 > 其它

重写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;

}

});

});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: