Commit a3d8d941 authored by Adrien Pavie's avatar Adrien Pavie
Browse files

Better handling of mapcss list retrieval in main controller

parent d508c5ff
......@@ -402,7 +402,7 @@ var Main = function(divId, mode, config) {
*/
Main.prototype._initConfig = function(config) {
//Update default config according to given one
$.extend(this.config, config);
$.extend(true, this.config, config);
//Load MapCSS styles
var that = this;
......@@ -424,19 +424,20 @@ Main.prototype._initConfig = function(config) {
});
//Then download them
console.log(this.styles);
for(var i=0; i < this.styles.length; i++) {
$.ajax({
url: this.config.map.styleFolder+'/'+this.styles[i],
async: false,
dataType: 'text',
success: function(data) {
var shortname = this.styles[i].replace(".mapcss", "").toLowerCase();
this.styles[i] = new RuleSet();
this.styles[i].parseCSS(data);
this.styles[i].olu_shortname = shortname;
}.bind(this)
}).fail(function() { throw new Error("[Controller] Error while retrieving MapCSS file: "+this.styles[i]); }.bind(this));
if(typeof this.styles[i] === 'string') {
$.ajax({
url: this.config.map.styleFolder+'/'+this.styles[i],
async: false,
dataType: 'text',
success: function(data) {
var shortname = this.styles[i].replace(".mapcss", "").toLowerCase();
this.styles[i] = new RuleSet();
this.styles[i].parseCSS(data);
this.styles[i].olu_shortname = shortname;
}.bind(this)
}).fail(function() { throw new Error("[Controller] Error while retrieving MapCSS file: "+this.styles[i]); }.bind(this));
}
}
}.bind(this)
}).fail(function() { throw new Error("[Controller] Error while retrieving MapCSS list"); });
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment