Add custom layer option to URL hash, fixes #1024.

Layer format is custom:http://url.com/{z}/{x}/{y}.jpg
This commit is contained in:
Tom MacWright
2013-04-18 17:34:27 -04:00
parent c8dcba31ad
commit f1604df4d0
2 changed files with 11 additions and 1 deletions

View File

@@ -133,7 +133,14 @@ window.iD = function () {
};
var q = iD.util.stringQs(location.hash.substring(1)), detected = false;
if (q.layer) {
if (q.layer && q.layer.indexOf('custom:') === 0) {
context.layers()[0]
.source(iD.BackgroundSource.template({
template: q.layer.replace(/^custom:/, ''),
name: 'Custom'
}));
detected = true;
} else if (q.layer) {
context.layers()[0]
.source(_.find(backgroundSources, function(l) {
if (l.data.sourcetag === q.layer) {

View File

@@ -163,6 +163,9 @@ iD.Background = function(backgroundType) {
function setHash(source) {
var tag = source.data && source.data.sourcetag;
if (!tag && source.data.name === 'Custom') {
tag = 'custom:' + source.data.template;
}
var q = iD.util.stringQs(location.hash.substring(1));
if (tag) {
q[backgroundType] = tag;