From 9c25c6259cc07b3a09e657e479e729c6511573e4 Mon Sep 17 00:00:00 2001 From: Aaron Griffith Date: Tue, 29 Mar 2011 05:48:40 -0400 Subject: [PATCH] added center to config.js, lets you set map center in world coords By default, it is set to spawn. Also I changed defaultZoom to 2, which looks better (the world used to show up as *tiny* by default). --- config.js | 5 ++++- googlemap.py | 3 +++ web_assets/functions.js | 8 ++++++-- world.py | 1 + 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/config.js b/config.js index 6be0893..78dfd7d 100644 --- a/config.js +++ b/config.js @@ -2,8 +2,11 @@ var config = { fileExt: '{imgformat}', tileSize: 384, - defaultZoom: 1, + defaultZoom: 2, maxZoom: {maxzoom}, + // center on this point, in world coordinates, ex: + //center: [0,0,0], + center: {spawn_coords}, cacheMinutes: 0, // Change this to have browsers automatically request new images every x minutes bg_color: '#1A1A1A', debug: false diff --git a/googlemap.py b/googlemap.py index 65fd8e8..2321049 100644 --- a/googlemap.py +++ b/googlemap.py @@ -94,6 +94,9 @@ class MapGen(object): config = config.replace( "{imgformat}", str(imgformat)) + config = config.replace("{spawn_coords}", + json.dumps(list(self.world.spawn))) + # create generated map type data, from given quadtrees maptypedata = map(lambda q: {'label' : q.rendermode.capitalize(), 'path' : q.tiledir}, self.quadtrees) diff --git a/web_assets/functions.js b/web_assets/functions.js index 3487d5b..0ec7eae 100644 --- a/web_assets/functions.js +++ b/web_assets/functions.js @@ -256,8 +256,12 @@ function initialize() { var query = location.search.substring(1); - var lat = 0.5; - var lng = 0.5; + var defaultCenter = fromWorldToLatLng(config.center[0], + config.center[1], + config.center[2]); + var lat = defaultCenter.lat(); + var lng = defaultCenter.lng(); + var zoom = config.defaultZoom; var pairs = query.split("&"); for (var i=0; i