diff --git a/config.js b/config.js index ac301cc..23416d0 100644 --- a/config.js +++ b/config.js @@ -36,12 +36,14 @@ var signGroups = [ * Required: * label : string. Displayed on the control. * path : string. Location of the rendered tiles. + * Optional: + * base : string. Base of the url path for tile locations, useful for serving tiles from a different server than the js/html server. */ var mapTypeData=[ {'label': 'Unlit', 'path': 'tiles'}, // {'label': 'Day', 'path': 'lighting/tiles'}, // {'label': 'Night', 'path': 'night/tiles'}, -// {'label': 'Spawn', 'path': 'spawn/tiles'} +// {'label': 'Spawn', 'path': 'spawn/tiles', 'base': 'http://example.cdn.amazon.com/'} ]; // Please leave the following variables here: diff --git a/web_assets/functions.js b/web_assets/functions.js index b7a8697..768a5c3 100644 --- a/web_assets/functions.js +++ b/web_assets/functions.js @@ -383,9 +383,10 @@ function initialize() { return new google.maps.LatLng(lat, lng); } -function getTileUrlGenerator(path) { +function getTileUrlGenerator(path, path_base) { return function(tile, zoom) { var url = path; + var url_base = ( path_base ? path_base : '' ); if(tile.x < 0 || tile.x >= Math.pow(2, zoom) || tile.y < 0 || tile.y >= Math.pow(2, zoom)) { url += '/blank'; } else if(zoom == 0) { @@ -402,7 +403,7 @@ function getTileUrlGenerator(path) { var d = new Date(); url += '?c=' + Math.floor(d.getTime() / (1000 * 60 * config.cacheMinutes)); } - return(url); + return(path_base + url); } } @@ -414,7 +415,7 @@ for (idx in mapTypeData) { var view = mapTypeData[idx]; MCMapOptions[view.label] = { - getTileUrl: getTileUrlGenerator(view.path), + getTileUrl: getTileUrlGenerator(view.path, view.base), tileSize: new google.maps.Size(config.tileSize, config.tileSize), maxZoom: config.maxZoom, minZoom: 0,