mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-23 00:29:50 +02:00
Calculate background source name (fixes #1935)
This commit is contained in:
@@ -28,7 +28,7 @@ iD.Background = function(context) {
|
||||
q = iD.util.stringQs(location.hash.substring(1));
|
||||
|
||||
var id = b.id;
|
||||
if (!id && b.name === 'Custom') {
|
||||
if (id === 'custom') {
|
||||
id = 'custom:' + b.template;
|
||||
}
|
||||
|
||||
@@ -46,17 +46,12 @@ iD.Background = function(context) {
|
||||
|
||||
location.replace('#' + iD.util.qsString(q, true));
|
||||
|
||||
var imageryUsed = [];
|
||||
if (b.name === 'Custom') {
|
||||
imageryUsed.push('Custom (' + b.template + ')');
|
||||
} else {
|
||||
imageryUsed.push(b.id || b.name);
|
||||
}
|
||||
var imageryUsed = [b.imageryUsed()];
|
||||
|
||||
overlayLayers.forEach(function (d) {
|
||||
var source = d.source();
|
||||
if (!source.isLocatorOverlay()) {
|
||||
imageryUsed.push(source.id || source.name);
|
||||
imageryUsed.push(source.imageryUsed());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -85,7 +80,7 @@ iD.Background = function(context) {
|
||||
gpx.call(gpxLayer);
|
||||
|
||||
var overlays = selection.selectAll('.overlay-layer')
|
||||
.data(overlayLayers, function(d) { return d.source().name; });
|
||||
.data(overlayLayers, function(d) { return d.source().name(); });
|
||||
|
||||
overlays.enter().insert('div', '.layer-data')
|
||||
.attr('class', 'layer-layer overlay-layer');
|
||||
@@ -166,7 +161,7 @@ iD.Background = function(context) {
|
||||
|
||||
background.showsLayer = function(d) {
|
||||
return d === baseLayer.source() ||
|
||||
(d.name === 'Custom' && baseLayer.source().name === 'Custom') ||
|
||||
(d.id === 'custom' && baseLayer.source().id === 'custom') ||
|
||||
overlayLayers.some(function(l) { return l.source() === d; });
|
||||
};
|
||||
|
||||
@@ -214,10 +209,7 @@ iD.Background = function(context) {
|
||||
chosen = q.background || q.layer;
|
||||
|
||||
if (chosen && chosen.indexOf('custom:') === 0) {
|
||||
background.baseLayerSource(iD.BackgroundSource({
|
||||
template: chosen.replace(/^custom:/, ''),
|
||||
name: 'Custom'
|
||||
}));
|
||||
background.baseLayerSource(iD.BackgroundSource.Custom(chosen.replace(/^custom:/, '')));
|
||||
} else {
|
||||
background.baseLayerSource(findSource(chosen) || findSource('Bing'));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
iD.BackgroundSource = function(data) {
|
||||
var source = _.clone(data),
|
||||
offset = [0, 0];
|
||||
offset = [0, 0],
|
||||
name = source.name;
|
||||
|
||||
source.scaleExtent = data.scaleExtent || [0, 20];
|
||||
|
||||
@@ -16,6 +17,14 @@ iD.BackgroundSource = function(data) {
|
||||
return source;
|
||||
};
|
||||
|
||||
source.name = function() {
|
||||
return name;
|
||||
};
|
||||
|
||||
source.imageryUsed = function() {
|
||||
return source.id || name;
|
||||
};
|
||||
|
||||
source.url = function(coord) {
|
||||
return data.template
|
||||
.replace('{x}', coord[0])
|
||||
@@ -42,7 +51,7 @@ iD.BackgroundSource = function(data) {
|
||||
};
|
||||
|
||||
source.isLocatorOverlay = function() {
|
||||
return source.name === 'Locator Overlay';
|
||||
return name === 'Locator Overlay';
|
||||
};
|
||||
|
||||
source.copyrightNotices = function() {};
|
||||
@@ -114,5 +123,29 @@ iD.BackgroundSource.Bing = function(data, dispatch) {
|
||||
};
|
||||
|
||||
iD.BackgroundSource.None = function() {
|
||||
return iD.BackgroundSource({ name: t('background.none'), id: 'None', template: '' });
|
||||
var source = iD.BackgroundSource({id: 'none', template: ''});
|
||||
|
||||
source.name = function() {
|
||||
return t('background.none');
|
||||
};
|
||||
|
||||
source.imageryUsed = function() {
|
||||
return 'None';
|
||||
};
|
||||
|
||||
return source;
|
||||
};
|
||||
|
||||
iD.BackgroundSource.Custom = function(template) {
|
||||
var source = iD.BackgroundSource({id: 'custom', template: template});
|
||||
|
||||
source.name = function() {
|
||||
return t('background.custom');
|
||||
};
|
||||
|
||||
source.imageryUsed = function() {
|
||||
return 'Custom (' + template + ')';
|
||||
};
|
||||
|
||||
return source;
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@ iD.ui.Attribution = function(context) {
|
||||
.attr('class', klass);
|
||||
|
||||
var background = div.selectAll('.attribution')
|
||||
.data(data, function(d) { return d.name; });
|
||||
.data(data, function(d) { return d.name(); });
|
||||
|
||||
background.enter()
|
||||
.append('span')
|
||||
@@ -22,7 +22,7 @@ iD.ui.Attribution = function(context) {
|
||||
return;
|
||||
}
|
||||
|
||||
var source = d.terms_text || d.id || d.name;
|
||||
var source = d.terms_text || d.id || d.name();
|
||||
|
||||
if (d.logo) {
|
||||
source = '<img class="source-image" src="' + context.imagePath(d.logo) + '">';
|
||||
|
||||
@@ -52,10 +52,7 @@ iD.ui.Background = function(context) {
|
||||
selectLayer();
|
||||
return;
|
||||
}
|
||||
context.background().baseLayerSource(iD.BackgroundSource({
|
||||
template: template,
|
||||
name: 'Custom'
|
||||
}));
|
||||
context.background().baseLayerSource(iD.BackgroundSource.Custom(template));
|
||||
selectLayer();
|
||||
}
|
||||
|
||||
@@ -76,7 +73,7 @@ iD.ui.Background = function(context) {
|
||||
.filter(filter);
|
||||
|
||||
var layerLinks = layerList.selectAll('li.layer')
|
||||
.data(sources, function(d) { return d.name; });
|
||||
.data(sources, function(d) { return d.name(); });
|
||||
|
||||
var enter = layerLinks.enter()
|
||||
.insert('li', '.custom_layer')
|
||||
@@ -96,7 +93,7 @@ iD.ui.Background = function(context) {
|
||||
.on('change', change);
|
||||
|
||||
label.append('span')
|
||||
.text(function(d) { return d.name; });
|
||||
.text(function(d) { return d.name(); });
|
||||
|
||||
layerLinks.exit()
|
||||
.remove();
|
||||
@@ -222,7 +219,7 @@ iD.ui.Background = function(context) {
|
||||
|
||||
var custom = backgroundList.append('li')
|
||||
.attr('class', 'custom_layer')
|
||||
.datum({name: 'Custom'});
|
||||
.datum(iD.BackgroundSource.Custom());
|
||||
|
||||
var label = custom.append('label');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user