0

cdn support

This commit is contained in:
aheadley
2011-01-27 10:45:53 -05:00
parent 850f4fcf7d
commit d1e3f660c9
2 changed files with 7 additions and 4 deletions

View File

@@ -36,12 +36,14 @@ var signGroups = [
* Required: * Required:
* label : string. Displayed on the control. * label : string. Displayed on the control.
* path : string. Location of the rendered tiles. * 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=[ var mapTypeData=[
{'label': 'Unlit', 'path': 'tiles'}, {'label': 'Unlit', 'path': 'tiles'},
// {'label': 'Day', 'path': 'lighting/tiles'}, // {'label': 'Day', 'path': 'lighting/tiles'},
// {'label': 'Night', 'path': 'night/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: // Please leave the following variables here:

View File

@@ -383,9 +383,10 @@ function initialize() {
return new google.maps.LatLng(lat, lng); return new google.maps.LatLng(lat, lng);
} }
function getTileUrlGenerator(path) { function getTileUrlGenerator(path, path_base) {
return function(tile, zoom) { return function(tile, zoom) {
var url = path; 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)) { if(tile.x < 0 || tile.x >= Math.pow(2, zoom) || tile.y < 0 || tile.y >= Math.pow(2, zoom)) {
url += '/blank'; url += '/blank';
} else if(zoom == 0) { } else if(zoom == 0) {
@@ -402,7 +403,7 @@ function getTileUrlGenerator(path) {
var d = new Date(); var d = new Date();
url += '?c=' + Math.floor(d.getTime() / (1000 * 60 * config.cacheMinutes)); 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]; var view = mapTypeData[idx];
MCMapOptions[view.label] = { MCMapOptions[view.label] = {
getTileUrl: getTileUrlGenerator(view.path), getTileUrl: getTileUrlGenerator(view.path, view.base),
tileSize: new google.maps.Size(config.tileSize, config.tileSize), tileSize: new google.maps.Size(config.tileSize, config.tileSize),
maxZoom: config.maxZoom, maxZoom: config.maxZoom,
minZoom: 0, minZoom: 0,