[OpenLayers-Users] Possibility to put a tiled image on
OpenLayers
Jimmy Aumard
jimmy.aumard at gmail.com
Fri Apr 23 09:04:52 EDT 2010
Thanks a lot Kris,
I have finally find the solution. This is my getURL function :
getURL: function(bounds) {
var res = this.map.getResolution();
var bbox = this.maxExtent;
var size = this.tileSize;
var tileX = Math.round((bounds.left - bbox.left) / (res * size.w));
var tileY = Math.round((bounds.bottom - bbox.bottom) / (res *
size.h));
var z = this.map.getZoom();
/**
* Zero-pad a positive integer.
* number - {Int}
* length - {Int}
*
* Returns:
* {String} A zero-padded string
*/
function zeroPad(number, length) {
number = String(number);
var zeros = [];
for(var i=0; i<length; ++i) {
zeros.push('0');
}
return zeros.join('').substring(0, length - number.length) +
number;
}
tileY = Math.ceil(this.zoomImages[z][1]/size.h) - tileY -1;
var pos= parseInt(tileY) * Math.ceil(this.zoomImages[z][0]/size.w) +
parseInt(tileX);
var components = [this.layername];
var path = components.join('/');
var url = this.url;
if (url instanceof Array) {
url = this.selectUrl(path, url);
}
url = (url.charAt(url.length - 1) == '/') ? url : url + '/';
return url + path+"/"+this.layername+"_"+(z)+"_"+zeroPad(pos,4) +
'.' + this.extension;
},
It's work for tiles like layerName_NbZoom_nbTile.extension.
Tile are like:
1 2 3 4
5 6 7 8
Hope this help someone else.
Cheers
Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100423/cd68f6d2/attachment.html
More information about the Users
mailing list