leaflet中对于动态图层的访问可以添加占位符并重写getTileUrl方法,现在我们要把leaflet替换为classic,请问classic中有相对应的实现方法吗?
使用产品:iserver 8c 810 操作系统:win7 x64
url路径:http://192.168.90.183:8080/tilesCHN/{z}/{y}/{x}.png
重写方式:
var markers = [];
L.TileLayer.TileLoad = L.TileLayer.extend({
initialize: function (url, options) {
options = L.setOptions(this, options);
this.url = url ;
//alert("ssss");
L.TileLayer.prototype.initialize.call(this, this.url, options);
}
});
/**
* 重写TileLayer中获取切片url方法
* @param {Object} tilePoint
*/
L.TileLayer.prototype.getTileUrl = function(tilePoint) {
return L.Util.template(this._url, L.extend({
s: this._getSubdomain(tilePoint),
z: function() {
var value = tilePoint.z.toString(16);
var ss=""
//alert(tilePoint.z);
if(tilePoint.z<10)
ss="L0" + tilePoint.z;
else
ss="L" + tilePoint.z;
console.log(tilePoint);
return ss;
},
x: function() {
var oo = "00000000"
var xx = tilePoint.x.toString(16);
xx = "C" + oo.substring(0, 8 - xx.length) + xx;
return xx;
},
y: function() {
var oo = "00000000"
var yy =tilePoint.y.toString(16);
yy = "R" + oo.substring(0, 8 - yy.length) + yy;
return yy;
}
}));
};
L.tileLayer.tileLoad = function(url, options){
return new L.TileLayer.TileLoad(url, options);
};