-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Add customAttribution option to AttributionControl #7033
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! A few nitpicks.
@@ -111,6 +113,13 @@ class AttributionControl { | |||
_updateAttributions() { | |||
if (!this._map.style) return; | |||
let attributions: Array<string> = []; | |||
if (this.options.customAttribution) { | |||
if (this.options.customAttribution instanceof Array) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use Array.isArray
instead — instanceof Array
can sometimes fail.
src/ui/map.js
Outdated
@@ -61,6 +61,7 @@ type MapOptions = { | |||
container: HTMLElement | string, | |||
bearingSnap?: number, | |||
attributionControl?: boolean, | |||
customAttribution?: string | string[], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use Array<string>
form for consistency.
btw, I noticed that running build locally adds |
@mklopets not intentionally, don't worry about it — we'll commit. |
@@ -16,6 +17,7 @@ type Options = { | |||
* @implements {IControl} | |||
* @param {Object} [options] | |||
* @param {boolean} [options.compact] If `true` force a compact attribution that shows the full attribution on mouse hover, or if `false` force the full attribution control. The default is a responsive attribution that collapses when the map is less than 640 pixels wide. | |||
* @param {string | Array<string>} [options.customAttribution] String or strings to show ahead of any other attributions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might just be me, but I think after
would be easier to understand in this context than ahead
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this JSDoc is incorrect, everything is sorted by length anyway – I'll change the doc. Thanks!
@mourner could we get this released? Would be much appreciated – needed in production. |
@mklopets unfortunately not at the moment — we're on a monthly release cadence so you should expect the new version in about 3 weeks. However, you can always build the |
Oh, alright :/ I tried looking up the release cadence from the docs here in the repo but couldn't find anything. Might be good to add a little note to Thanks for the quick response(s)! |
Adds feature: mapbox/mapbox-gl-js#7033
Adds feature: mapbox/mapbox-gl-js#7033
Adds a way to add custom attribution strings to AttributionControl. Also exposes the
customAttribution
option on Map.This implements the feature request in #1485.