From af367f9aa9ccffe439a9539c438462c230ee65e1 Mon Sep 17 00:00:00 2001 From: javi Date: Fri, 23 Aug 2013 18:00:42 +0200 Subject: [PATCH] add support for multiple subdomains --- lib/torque/provider.jsonarray.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/torque/provider.jsonarray.js b/lib/torque/provider.jsonarray.js index 06d4e07..7ae9ade 100644 --- a/lib/torque/provider.jsonarray.js +++ b/lib/torque/provider.jsonarray.js @@ -161,12 +161,18 @@ }, - getTile: function(coord, zoom, callback) { + tileUrl: function(coord, zoom) { var template = this.url(); - template = template + var s = (this.options.subdomains || 'abcd')[(coord.x + coord.y + zoom) % 4]; + return template .replace('{x}', coord.x) .replace('{y}', coord.y) - .replace('{z}', zoom); + .replace('{z}', zoom) + .replace('{s}', s); + }, + + getTile: function(coord, zoom, callback) { + var template = this.tileUrl(coord, zoom); var self = this; var fetchTime = Profiler.metric('jsonarray:fetch time'); @@ -185,11 +191,7 @@ * `zoom` quadtree zoom level */ getTileData: function(coord, zoom, callback) { - var template = this.url(); - template = template - .replace('{x}', coord.x) - .replace('{y}', coord.y) - .replace('{z}', zoom); + var template = this.tileUrl(coord, zoom); var self = this; var fetchTime = Profiler.metric('jsonarray:fetch time');