Skip to content

Commit 6b87ef7

Browse files
committed
mapbox: add layout attribute 'sourceattribution'
1 parent 218a919 commit 6b87ef7

File tree

7 files changed

+149
-4
lines changed

7 files changed

+149
-4
lines changed

src/plots/mapbox/constants.js

+32-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/plots/mapbox/layers.js

+2
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ function convertSourceOpts(opts) {
219219

220220
sourceOpts[field] = source;
221221

222+
if(opts.sourceattribution) sourceOpts.attribution = opts.sourceattribution;
223+
222224
return sourceOpts;
223225
}
224226

src/plots/mapbox/layout_attributes.js

+8
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,14 @@ var attrs = module.exports = overrideAll({
131131
].join(' ')
132132
},
133133

134+
sourceattribution: {
135+
valType: 'string',
136+
role: 'info',
137+
description: [
138+
'Sets the attribution for this source.'
139+
].join(' ')
140+
},
141+
134142
type: {
135143
valType: 'enumerated',
136144
values: ['circle', 'line', 'fill', 'symbol', 'raster'],

src/plots/mapbox/layout_defaults.js

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ function handleLayerDefaults(layerIn, layerOut) {
5454
var mustBeRasterLayer = sourceType === 'raster' || sourceType === 'image';
5555

5656
coerce('source');
57+
coerce('sourceattribution');
5758

5859
if(sourceType === 'vector') {
5960
coerce('sourcelayer');

src/plots/mapbox/mapbox.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,14 @@ proto.createMap = function(calcData, fullLayout, resolve, reject) {
104104
preserveDrawingBuffer: self.isStatic,
105105

106106
doubleClickZoom: false,
107-
boxZoom: false
108-
});
107+
boxZoom: false,
108+
109+
attributionControl: false
110+
})
111+
.addControl(new mapboxgl.AttributionControl({
112+
compact: true
113+
}));
114+
109115

110116
// make sure canvas does not inherit left and top css
111117
map._canvas.style.left = '0px';

src/registry.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ function registerTraceModule(_module) {
276276
if(bpmName === 'mapbox') {
277277
var styleRules = basePlotModule.constants.styleRules;
278278
for(var k in styleRules) {
279-
addStyleRule('.mapboxgl-' + k, styleRules[k]);
279+
addStyleRule('.js-plotly-plot .plotly .mapboxgl-' + k, styleRules[k]);
280280
}
281281
}
282282

0 commit comments

Comments
 (0)