Open sansumbrella opened 4 years ago
Note that adding mapbox-gl.css
alongside mapbox-gl.js
is required for correct operation of the map in general — otherwise many features won't work, not just attribution: all the controls (buttons, compass, scale control, search etc.), cursors, interactions like shift-drag-zoom, HTML markers and popups, etc.
Currently, if you don't include CSS, there will be a warning about it in the developer console. We don't want to support CSS-less GL JS usage at all, so moving attribution support to JS is not a good option. Would you rather suggest disabling the map completely in this case?
I agree with @mourner here, the css is required, and don't think we should try and support a CSS-less GL JS. I think the current console warning is enough.
Motivation
Correctly attributing Mapbox on a map should be the easy default when using the gl-js library.
Currently, application developers must add a line of code in order to add attribution to their maps. This is easily forgotten in an HTML page, and a bit tricky to figure out how to do when using a bundler like Webpack. This makes it harder to correctly attribute Mapbox than it is to leave off attribution.
Design Alternatives
Require application code to remove attribution.
Current state
With external CSS loaded (attribution appears correctly):
Without external CSS loaded (no attribution):
HTML pages must source the correct (matching) version of CSS to add attribution, e.g.:
<link href="https://api.mapbox.com/mapbox-gl-js/v1.8.0/mapbox-gl.css" rel="stylesheet" />
Bundled applications can source the CSS from their node_modules folder and importing it close to where they use Mapbox, e.g.:
import 'mapbox-gl/dist/mapbox-gl.css';