[OpenLayers-Users] TMS parsing algorithm
Robert Buckley
robertdbuckley at yahoo.com
Wed Apr 18 09:38:25 EDT 2012
Hi,
I am trying to display a tms layer using openlayers by modifying some code which displays cloudmade layers
I have some code which tries to construct the tile but it is failing throwing this error...
400: Unable to parse number For input string: "zgb:RROP08 at EPSG:900913 at png8" from tms/1.0.0/zgb:RROP08 at EPSG:900913 at png8/134/81.png
I have obviously got it totally wrong.....Could anyone direct me to the documentation or say how to correctly parse the wms path?
yours,
Rob
//Code
OpenLayers.Layer.MyTMSClass = OpenLayers.Class(OpenLayers.Layer.TMS, {
initialize: function(name, options) {
options = OpenLayers.Util.extend({
attribution: "",
maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
maxResolution: 156543.0339,
units: "m",
projection: "EPSG:900913",
isBaseLayer: true,
numZoomLevels: 19,
displayOutsideMaxExtent: true,
wrapDateLine: true,
styleId: 1
}, options);
var prefix = [options.key, options.styleId, 256].join('/') + '/';
var url = [
"http://mydomain/geoserver/gwc/service/tms/1.0.0/zgb%3ARROP08@EPSG%3A900913@png"
];
var newArguments = [name, url, options];
OpenLayers.Layer.TMS.prototype.initialize.apply(this, newArguments);
},
getURL: function (bounds) {
var res = this.map.getResolution();
var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));
var y = Math.round((this.maxExtent.top - bounds.top) / (res * this.tileSize.h));
var z = this.map.getZoom();
var limit = Math.pow(2, z);
if (y < 0 || y >= limit)
{
return "http://cloudmade.com/js-api/images/empty-tile.png";
}
else
{
x = ((x % limit) + limit) % limit;
var url = this.url;
var path = z + "/" + x + "/" + y + ".png";
if (url instanceof Array)
{
url = this.selectUrl(path, url);
}
return url + path;
}
},
CLASS_NAME: "OpenLayers.Layer.MyTMSClass "
});
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120418/5b009b77/attachment-0001.html
More information about the Users
mailing list