From d1e3f660c9592ce6b527debfee32f27bcefa65b3 Mon Sep 17 00:00:00 2001 From: aheadley Date: Thu, 27 Jan 2011 10:45:53 -0500 Subject: [PATCH 1/3] cdn support --- config.js | 4 +++- web_assets/functions.js | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) 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, From 4a6d7f76ea44129c92aa47df4bf2e399da6c8ebd Mon Sep 17 00:00:00 2001 From: aheadley Date: Thu, 27 Jan 2011 10:59:07 -0500 Subject: [PATCH 2/3] background color support --- config.js | 1 + web_assets/functions.js | 1 + 2 files changed, 2 insertions(+) diff --git a/config.js b/config.js index 23416d0..c841130 100644 --- a/config.js +++ b/config.js @@ -5,6 +5,7 @@ defaultZoom: 1, maxZoom: {maxzoom}, cacheMinutes: 0, // Change this to have browsers automatically request new images every x minutes + bg_color: '#1A1A1A', debug: false }; diff --git a/web_assets/functions.js b/web_assets/functions.js index 768a5c3..478b04f 100644 --- a/web_assets/functions.js +++ b/web_assets/functions.js @@ -280,6 +280,7 @@ function initialize() { }, mapTypeId: mapTypeIdDefault, streetViewControl: false, + backgroundColor: config.bg_color, }; map = new google.maps.Map(document.getElementById('mcmap'), mapOptions); From 62aab91f13989257283b58cbaab7179cabbe3766 Mon Sep 17 00:00:00 2001 From: aheadley Date: Wed, 2 Feb 2011 10:59:27 -0500 Subject: [PATCH 3/3] fixed typo --- web_assets/functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_assets/functions.js b/web_assets/functions.js index 478b04f..9b42fda 100644 --- a/web_assets/functions.js +++ b/web_assets/functions.js @@ -404,7 +404,7 @@ function getTileUrlGenerator(path, path_base) { var d = new Date(); url += '?c=' + Math.floor(d.getTime() / (1000 * 60 * config.cacheMinutes)); } - return(path_base + url); + return(url_base + url); } }