Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise attributions of Carto, Stamen and Open Street Map styles #5696

Merged
merged 12 commits into from
Jun 2, 2021
34 changes: 28 additions & 6 deletions src/plots/mapbox/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,36 @@

var requiredVersion = '1.10.1';

var OSM = '© <a target="_blank" href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors';
var carto = [
'© <a target="_blank" href="https://carto.com/">Carto</a>',
OSM
].join(' ');

var stamenTerrainOrToner = [
'Map tiles by <a target="_blank" href="https://stamen.com">Stamen Design</a>',
'under <a target="_blank" href="https://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>',
'|',
'Data by <a target="_blank" href="https://openstreetmap.org">OpenStreetMap</a> contributors',
'under <a target="_blank" href="https://www.openstreetmap.org/copyright">ODbL</a>'
].join(' ');

var stamenWaterColor = [
'Map tiles by <a target="_blank" href="https://stamen.com">Stamen Design</a>',
'under <a target="_blank" href="https://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>',
'|',
'Data by <a target="_blank" href="https://openstreetmap.org">OpenStreetMap</a> contributors',
'under <a target="_blank" href="https://creativecommons.org/licenses/by-sa/3.0">CC BY SA</a>'
].join(' ');

var stylesNonMapbox = {
'open-street-map': {
id: 'osm',
version: 8,
sources: {
'plotly-osm-tiles': {
type: 'raster',
attribution: '<a href="http://www.openstreetmap.org/about/" target="_blank">© OpenStreetMap</a>',
attribution: OSM,
tiles: [
'https://a.tile.openstreetmap.org/{z}/{x}/{y}.png',
'https://b.tile.openstreetmap.org/{z}/{x}/{y}.png'
Expand Down Expand Up @@ -43,7 +65,7 @@ var stylesNonMapbox = {
sources: {
'plotly-carto-positron': {
type: 'raster',
attribution: '<a href="https://carto.com/" target="_blank">© CARTO</a>',
attribution: carto,
tiles: ['https://cartodb-basemaps-c.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png'],
tileSize: 256
}
Expand All @@ -62,7 +84,7 @@ var stylesNonMapbox = {
sources: {
'plotly-carto-darkmatter': {
type: 'raster',
attribution: '<a href="https://carto.com/" target="_blank">© CARTO</a>',
attribution: carto,
tiles: ['https://cartodb-basemaps-c.global.ssl.fastly.net/dark_all/{z}/{x}/{y}.png'],
tileSize: 256
}
Expand All @@ -81,7 +103,7 @@ var stylesNonMapbox = {
sources: {
'plotly-stamen-terrain': {
type: 'raster',
attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> | Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://www.openstreetmap.org/copyright">ODbL</a>.',
attribution: stamenTerrainOrToner,
tiles: ['https://stamen-tiles.a.ssl.fastly.net/terrain/{z}/{x}/{y}.png'],
tileSize: 256
}
Expand All @@ -100,7 +122,7 @@ var stylesNonMapbox = {
sources: {
'plotly-stamen-toner': {
type: 'raster',
attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> | Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://www.openstreetmap.org/copyright">ODbL</a>.',
attribution: stamenTerrainOrToner,
tiles: ['https://stamen-tiles.a.ssl.fastly.net/toner/{z}/{x}/{y}.png'],
tileSize: 256
}
Expand All @@ -119,7 +141,7 @@ var stylesNonMapbox = {
sources: {
'plotly-stamen-watercolor': {
type: 'raster',
attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> | Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://creativecommons.org/licenses/by-sa/3.0">CC BY SA</a>.',
attribution: stamenWaterColor,
tiles: ['https://stamen-tiles.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.png'],
tileSize: 256
}
Expand Down
Binary file modified test/image/baselines/mapbox_carto-style.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/mapbox_density0-legend.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/mapbox_osm-style.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/mapbox_stamen-style.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 67 additions & 1 deletion test/jasmine/tests/mapbox_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1471,12 +1471,73 @@ describe('mapbox plots', function() {
}, LONG_TIMEOUT_INTERVAL);

describe('attributions', function() {
function assertLinks(s, exp) {
var elements = s[0][0].getElementsByTagName('a');
expect(elements.length).toEqual(exp.length);
for(var i = 0; i < elements.length; i++) {
var e = elements[i];
expect(e.href).toEqual(exp[i]);
expect(e.target).toEqual('_blank');
}
}

it('@gl should be displayed for style "Carto"', function(done) {
Plotly.newPlot(gd, [{type: 'scattermapbox'}], {mapbox: {style: 'carto-darkmatter'}})
.then(function() {
var s = d3SelectAll('.mapboxgl-ctrl-attrib');
expect(s.size()).toBe(1);
expect(s.text()).toEqual('© Carto © OpenStreetMap contributors');
assertLinks(s, [
'https://carto.com/',
'https://www.openstreetmap.org/copyright'
]);
})
.then(done, done.fail);
});

['stamen-terrain', 'stamen-toner'].forEach(function(style) {
it('@gl should be displayed for style "' + style + '"', function(done) {
Plotly.newPlot(gd, [{type: 'scattermapbox'}], {mapbox: {style: style}})
.then(function() {
var s = d3SelectAll('.mapboxgl-ctrl-attrib');
expect(s.size()).toBe(1);
expect(s.text()).toEqual('Map tiles by Stamen Design under CC BY 3.0 | Data by OpenStreetMap contributors under ODbL');
assertLinks(s, [
'https://stamen.com/',
'https://creativecommons.org/licenses/by/3.0',
'https://openstreetmap.org/',
'https://www.openstreetmap.org/copyright'
]);
})
.then(done, done.fail);
});
});

it('@gl should be displayed for style "stamen-watercolor"', function(done) {
Plotly.newPlot(gd, [{type: 'scattermapbox'}], {mapbox: {style: 'stamen-watercolor'}})
.then(function() {
var s = d3SelectAll('.mapboxgl-ctrl-attrib');
expect(s.size()).toBe(1);
expect(s.text()).toEqual('Map tiles by Stamen Design under CC BY 3.0 | Data by OpenStreetMap contributors under CC BY SA');
assertLinks(s, [
'https://stamen.com/',
'https://creativecommons.org/licenses/by/3.0',
'https://openstreetmap.org/',
'https://creativecommons.org/licenses/by-sa/3.0'
]);
})
.then(done, done.fail);
});

it('@gl should be displayed for style "open-street-map"', function(done) {
Plotly.newPlot(gd, [{type: 'scattermapbox'}], {mapbox: {style: 'open-street-map'}})
.then(function() {
var s = d3SelectAll('.mapboxgl-ctrl-attrib');
expect(s.size()).toBe(1);
expect(s.text()).toEqual('© OpenStreetMap');
expect(s.text()).toEqual('© OpenStreetMap contributors');
assertLinks(s, [
'https://www.openstreetmap.org/copyright'
]);
})
.then(done, done.fail);
});
Expand All @@ -1487,6 +1548,11 @@ describe('mapbox plots', function() {
var s = d3SelectAll('.mapboxgl-ctrl-attrib');
expect(s.size()).toBe(1);
expect(s.text()).toEqual('© Mapbox © OpenStreetMap Improve this map');
assertLinks(s, [
'https://www.mapbox.com/about/maps/',
'http://www.openstreetmap.org/about/',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexcjohnson any suggestion on how to replace this http link with https?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is coming from MapboxGL.js let's just leave it for now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. It's coming from there.

'https://www.mapbox.com/map-feedback/' // Improve this map
]);
})
.then(done, done.fail);
});
Expand Down