Override the TiledMapServiceLayer of ArcGIS to call the world map tile,

Source: Internet
Author: User

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;
}
});


});

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.