tilecache的起始坐标为右上角的点
3.openlayer 调用arcgis的切片的关键代码
var test=new OpenLayers.Layer.TMS(
"ditu",
"",
{
layerName: 'qgm', type: "png", 'getURL': function (bounds) {
var res = map.getResolution();
var bbox = this.map.getMaxExtent();
var size = this.tileSize;
var tileX = Math.round((bounds.left - bbox.left) / (res * size.w));
var tileY = Math.round((bbox.top-bounds.top) / (res * size.h));
var tileZ = this.map.zoom;
if(tileZ == 3 && tileX > (Math.pow(2, tileZ) - 1)){
tileX = tileX-Math.pow(2, tileZ);
}
if(tileX < 0){tileX = tileX + Math.round(bbox.getWidth() / bounds.getWidth());}
if(tileY < 0){tileY = tileY + Math.round(bbox.getHeight() / bounds.getHeight());}
return "Layers/_alllayers/L" + convert16(2,z) + "/R" + convert16(8,y) + "/C" +convert16(8,x) + ".png";
*/
return "Layers/_alllayers/L" + convert16(2,tileZ) + "/R" + convert16(8,tileY) + "/C" +convert16(8,tileX) + ".png";
}
}
);
function convert16(length,value){
var v=Math.abs(value);
var s=v.toString(16);
var len=length-s.length;
var tmp="";
for(var i=0;i<len;i++){
tmp+="0";
}
return tmp+s;
}
4.openlayers调用tilecache切片的关键代码
var test=new OpenLayers.Layer.TMS(
quanguoditu,
"",
{
layerName: 'qgm', type: "png", 'getURL': function (bounds) {
var res = map.getResolution();
var x = Math.round((bounds.left - map.maxExtent.left) / (res * 256));
var y = Math.round((bounds.bottom - map.maxExtent.bottom) / (res * 256)); //从下面往上计算
var z = this.map.getZoom();
return CACHETMSURL + z + "/" + x + "/" + y + ".png";
}
}
);
在此感谢网友“GIS-xyz”和“赵钊烽”给予的代码支持。