mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-14 17:52:55 +00:00
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:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user