mirror of
https://github.com/FoggedLens/iD.git
synced 2026-06-03 21:48:03 +02:00
Store background setting in hash. Fixes #632
This commit is contained in:
+13
-4
@@ -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');
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user