Override the TiledMapServiceLayer of ArcGIS to call the world map tile,
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 levels = {
"Level": I,
"Resolution": tempResolution,
"Scale": tempScale
}
If (I> = startLevel ){
Lods. push (lods );
}
TempScale = tempScale/2;
TempResolution = tempResolution/2;
}
Return lods;
},
_ GetMapInfo: function (){
Var result = {
MapName :"",
LayerId :"",
TileMatrixSetId :""
};
If (this. _ mapStyle = "ImageBaseMap "){
// Obtain the image (basemap)
Result. mapName = "img_c ";
Result. layerId = "img ";
Result. tileMatrixSetId = "c ";
} Else if (this. _ mapStyle = "ImageCNNote "){
// Obtain the image (Chinese note)
Result. mapName = "cia_c ";
Result. layerId = "cia ";
Result. tileMatrixSetId = "c ";
} Else if (this. _ mapStyle = "ImageENNote "){
// Obtain the image (English note)
Result. mapName = "eia_c ";
Result. layerId = "eia ";
Result. tileMatrixSetId = "c ";
} Else if (this. _ mapStyle = "TerrainBaseMap "){
// Obtain the Topographic Map (basemap)
Result. mapName = "ter_c ";
Result. layerId = "ter ";
Result. tileMatrixSetId = "c ";
} Else if (this. _ mapStyle = "TerrainCNNote "){
// Obtain the Topographic Map (Chinese note)
Result. mapName = "cta_c ";
Result. layerId = "cta ";
Result. tileMatrixSetId = "c ";
} Else if (this. _ mapStyle = "TerrainENNote "){
// Obtain topographic maps (note)
} Else if (this. _ mapStyle = "VectorBaseMap "){
// Obtain the map (basemap)
Result. mapName = "vec_c ";
Result. layerId = "vec ";
Result. tileMatrixSetId = "c ";
} Else if (this. _ mapStyle = "VectorCNNote "){
// Obtain the map (Chinese note)
Result. mapName = "cva_c ";
Result. layerId = "cva ";
Result. tileMatrixSetId = "c ";
} Else if (this. _ mapStyle = "VectorENNote "){
// Obtain the map (English note)
Result. mapName = "eva_c ";
Result. layerId = "eva ";
Result. tileMatrixSetId = "c ";
}
Return result;
}
});
});