diff --git a/src/plots/mapbox/constants.js b/src/plots/mapbox/constants.js
index 2568b89a6fb..ac1a3110bf4 100644
--- a/src/plots/mapbox/constants.js
+++ b/src/plots/mapbox/constants.js
@@ -2,6 +2,28 @@
var requiredVersion = '1.10.1';
+var OSM = '© OpenStreetMap contributors';
+var carto = [
+ '© Carto',
+ OSM
+].join(' ');
+
+var stamenTerrainOrToner = [
+ 'Map tiles by Stamen Design',
+ 'under CC BY 3.0',
+ '|',
+ 'Data by OpenStreetMap contributors',
+ 'under ODbL'
+].join(' ');
+
+var stamenWaterColor = [
+ 'Map tiles by Stamen Design',
+ 'under CC BY 3.0',
+ '|',
+ 'Data by OpenStreetMap contributors',
+ 'under CC BY SA'
+].join(' ');
+
var stylesNonMapbox = {
'open-street-map': {
id: 'osm',
@@ -9,7 +31,7 @@ var stylesNonMapbox = {
sources: {
'plotly-osm-tiles': {
type: 'raster',
- attribution: '© OpenStreetMap',
+ attribution: OSM,
tiles: [
'https://a.tile.openstreetmap.org/{z}/{x}/{y}.png',
'https://b.tile.openstreetmap.org/{z}/{x}/{y}.png'
@@ -43,7 +65,7 @@ var stylesNonMapbox = {
sources: {
'plotly-carto-positron': {
type: 'raster',
- attribution: '© CARTO',
+ attribution: carto,
tiles: ['https://cartodb-basemaps-c.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png'],
tileSize: 256
}
@@ -62,7 +84,7 @@ var stylesNonMapbox = {
sources: {
'plotly-carto-darkmatter': {
type: 'raster',
- attribution: '© CARTO',
+ attribution: carto,
tiles: ['https://cartodb-basemaps-c.global.ssl.fastly.net/dark_all/{z}/{x}/{y}.png'],
tileSize: 256
}
@@ -81,7 +103,7 @@ var stylesNonMapbox = {
sources: {
'plotly-stamen-terrain': {
type: 'raster',
- attribution: 'Map tiles by Stamen Design, under CC BY 3.0 | Data by OpenStreetMap, under ODbL.',
+ attribution: stamenTerrainOrToner,
tiles: ['https://stamen-tiles.a.ssl.fastly.net/terrain/{z}/{x}/{y}.png'],
tileSize: 256
}
@@ -100,7 +122,7 @@ var stylesNonMapbox = {
sources: {
'plotly-stamen-toner': {
type: 'raster',
- attribution: 'Map tiles by Stamen Design, under CC BY 3.0 | Data by OpenStreetMap, under ODbL.',
+ attribution: stamenTerrainOrToner,
tiles: ['https://stamen-tiles.a.ssl.fastly.net/toner/{z}/{x}/{y}.png'],
tileSize: 256
}
@@ -119,7 +141,7 @@ var stylesNonMapbox = {
sources: {
'plotly-stamen-watercolor': {
type: 'raster',
- attribution: 'Map tiles by Stamen Design, under CC BY 3.0 | Data by OpenStreetMap, under CC BY SA.',
+ attribution: stamenWaterColor,
tiles: ['https://stamen-tiles.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.png'],
tileSize: 256
}
diff --git a/test/image/baselines/mapbox_carto-style.png b/test/image/baselines/mapbox_carto-style.png
index 8262c827ec0..ec67e788736 100644
Binary files a/test/image/baselines/mapbox_carto-style.png and b/test/image/baselines/mapbox_carto-style.png differ
diff --git a/test/image/baselines/mapbox_density0-legend.png b/test/image/baselines/mapbox_density0-legend.png
index fd83969016f..59529644c16 100644
Binary files a/test/image/baselines/mapbox_density0-legend.png and b/test/image/baselines/mapbox_density0-legend.png differ
diff --git a/test/image/baselines/mapbox_osm-style.png b/test/image/baselines/mapbox_osm-style.png
index 39cf9a292e5..c5e360e1e3b 100644
Binary files a/test/image/baselines/mapbox_osm-style.png and b/test/image/baselines/mapbox_osm-style.png differ
diff --git a/test/image/baselines/mapbox_stamen-style.png b/test/image/baselines/mapbox_stamen-style.png
index 5d57cb266e4..c83e372205b 100644
Binary files a/test/image/baselines/mapbox_stamen-style.png and b/test/image/baselines/mapbox_stamen-style.png differ
diff --git a/test/jasmine/tests/mapbox_test.js b/test/jasmine/tests/mapbox_test.js
index 769e127f72f..d39400f70f3 100644
--- a/test/jasmine/tests/mapbox_test.js
+++ b/test/jasmine/tests/mapbox_test.js
@@ -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);
});
@@ -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/',
+ 'https://www.mapbox.com/map-feedback/' // Improve this map
+ ]);
})
.then(done, done.fail);
});