Rewrite ArcGIS Tiledmapservicelayer to call the world map tile

Source: Internet
Author: User

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") {
Get Imagery (Basemap)
Result.mapname = "Img_c";
Result.layerid = "img";
Result.tilematrixsetid = "C";
} else if (This._mapstyle = = "Imagecnnote") {
Get images (Chinese annotation)
Result.mapname = "Cia_c";
Result.layerid = "CIA";
Result.tilematrixsetid = "C";
} else if (This._mapstyle = = "Imageennote") {
Get Imagery (English annotation)
Result.mapname = "Eia_c";
Result.layerid = "EIA";
Result.tilematrixsetid = "C";
} else if (This._mapstyle = = "Terrainbasemap") {
Get topographic map (BASEMAP)
Result.mapname = "Ter_c";
Result.layerid = "ter";
Result.tilematrixsetid = "C";
} else if (This._mapstyle = = "Terraincnnote") {
Get topographic map (Chinese note)
Result.mapname = "Cta_c";
Result.layerid = "CTA";
Result.tilematrixsetid = "C";
} else if (This._mapstyle = = "Terrainennote") {
Get topographic map (English note)
} else if (This._mapstyle = = "Vectorbasemap") {
Get a map (basemap)
Result.mapname = "Vec_c";
Result.layerid = "VEC";
Result.tilematrixsetid = "C";
} else if (This._mapstyle = = "Vectorcnnote") {
Get a map (Chinese annotation)
Result.mapname = "Cva_c";
Result.layerid = "CVA";
Result.tilematrixsetid = "C";
} else if (This._mapstyle = = "Vectorennote") {
Get a map (English note)
Result.mapname = "Eva_c";
Result.layerid = "Eva";
Result.tilematrixsetid = "C";
}


return result;
}
});


});

Copyright notice: This article Bo Master original article. Blog, not reproduced without consent.

Rewrite ArcGIS Tiledmapservicelayer to call the world map tile

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.