Store background setting in hash. Fixes #632

This commit is contained in:
Tom MacWright
2013-02-09 17:34:44 -05:00
parent f56e27ad2a
commit d9b5816530
2 changed files with 26 additions and 4 deletions
+13 -4
View File
@@ -92,10 +92,19 @@ window.iD = function () {
return context;
};
context.background()
.source(_.find(iD.layers, function(l) {
return l.data.name === 'Bing aerial imagery';
}));
var q = iD.util.stringQs(location.hash.substring(1));
if (q.layer) {
context.background()
.source(_.find(iD.layers, function(l) {
return l.data.sourcetag === q.layer;
}));
}
if (!context.background()) {
context.background()
.source(_.find(iD.layers, function(l) {
return l.data.name === 'Bing aerial imagery';
}));
}
return d3.rebind(context, dispatch, 'on');
};
+13
View File
@@ -152,9 +152,22 @@ iD.Background = function() {
return background;
};
function setPermalink(source) {
var tag = source.data.sourcetag;
var q = iD.util.stringQs(location.hash.substring(1));
if (tag) {
location.replace('#' + iD.util.qsString(_.assign(q, {
layer: tag
}), true));
} else {
location.replace('#' + iD.util.qsString(_.omit(q, 'layer'), true));
}
}
background.source = function(_) {
if (!arguments.length) return source;
source = _;
setPermalink(source);
return background;
};