From eea97d1b1c3a5f793f18f5248450456e22406a36 Mon Sep 17 00:00:00 2001 From: Alex Headley Date: Fri, 22 Apr 2011 11:11:14 -0400 Subject: [PATCH] added per-rendermode bg_color setting --- config.js | 1 - googlemap.py | 3 ++- web_assets/functions.js | 16 +++++++++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/config.js b/config.js index 41ee9e4..6ccd3ee 100644 --- a/config.js +++ b/config.js @@ -7,7 +7,6 @@ //center: [0,0,0], center: {spawn_coords}, cacheMinutes: 0, // Change this to have browsers automatically request new images every x minutes - bg_color: '{bg_color}', // You can set this in settings.py debug: false }; diff --git a/googlemap.py b/googlemap.py index 9e04b22..868297c 100644 --- a/googlemap.py +++ b/googlemap.py @@ -95,11 +95,12 @@ class MapGen(object): config = config.replace("{spawn_coords}", json.dumps(list(self.world.spawn))) - config = config.replace("{bg_color}", self.bg_color) + #config = config.replace("{bg_color}", self.bg_color) # create generated map type data, from given quadtrees maptypedata = map(lambda q: {'label' : q.rendermode.capitalize(), 'path' : q.tiledir, + 'bg_color': self.bg_color, 'overlay' : 'overlay' in get_render_mode_inheritance(q.rendermode), 'imgformat' : q.imgformat}, self.quadtrees) diff --git a/web_assets/functions.js b/web_assets/functions.js index b8ace5e..639970a 100644 --- a/web_assets/functions.js +++ b/web_assets/functions.js @@ -477,7 +477,6 @@ function initialize() { }, mapTypeId: mapTypeIdDefault, streetViewControl: false, - backgroundColor: config.bg_color, }; map = new google.maps.Map(document.getElementById('mcmap'), mapOptions); @@ -501,9 +500,6 @@ function initialize() { map.mapTypes.set('mcmap' + MCMapType[idx].name, MCMapType[idx]); } - // We can now set the map to use the 'coordinate' map type - map.setMapTypeId(mapTypeIdDefault); - // initialize the markers and regions initMarkers(); initRegions(); @@ -518,7 +514,17 @@ function initialize() { google.maps.event.addListener(map, 'center_changed', function() { makeLink(); }); - + google.maps.event.addListener(map, 'maptypeid_changed', function() { + var newType = map.getMapTypeId(); + for(i in mapTypeData) { + if( 'mcmap' + mapTypeData[i].label == newType ) { + $('#mcmap').css('background-color', mapTypeData[i].bg_color); + break; + } + } + }); + // We can now set the map to use the 'coordinate' map type + map.setMapTypeId(mapTypeIdDefault); }