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

add Mapbox wordmark as LogoControl #3933

Merged
merged 5 commits into from Jan 27, 2017
Merged

add Mapbox wordmark as LogoControl #3933

merged 5 commits into from Jan 27, 2017

Conversation

mollymerp
Copy link
Contributor

@mollymerp mollymerp commented Jan 10, 2017

Launch Checklist

closes #1825

  • briefly describe the changes in this PR
  • write tests for all new functionality
  • document any changes to public APIs
  • post benchmark scores
  • manually test the debug page

@mollymerp mollymerp force-pushed the wordmark-control branch 2 times, most recently from 18274a3 to 69fbb02 Compare January 10, 2017 02:02

class LogoControl {
constructor() {
}
Copy link
Member

Choose a reason for hiding this comment

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

you can omit empty constructors

}

onAdd(map) {
this._map = map;
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to save the map reference if it's not used by the control?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess we don't! I was following the IControl docs, but you're right it isn't necessary in this case.

@@ -200,6 +203,7 @@ class Map extends Camera {
if (options.style) this.setStyle(options.style);

if (options.attributionControl) this.addControl(new AttributionControl());
if (options.logoControl) this.addControl(new LogoControl(), 'bottom-left');
Copy link
Member

Choose a reason for hiding this comment

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

I think it's better to code the default position in the control code by adding a getDefaultPosition method.

Copy link
Contributor

@jfirebaugh jfirebaugh left a comment

Choose a reason for hiding this comment

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

The equivalent control in Mapbox.js is shown or hidden automatically based on a status flag returned by the Mapbox API. We'll likely need to implement a similar facility in the Styles API.

@mollymerp
Copy link
Contributor Author

@jfirebaugh do you mean we should punt on this until we implement something at the TileJSON level?

I'm looking in to what implementing a flag like that looks like, but some enterprise customers will still need to be able to remove the logo even if they're using our vector tiles depending on the terms of their Enterprise agreement.

@mollymerp
Copy link
Contributor Author

mollymerp commented Jan 11, 2017

Per chat in slack and convos w @sean-heff @ErinQuinn I think we should add the logo as on by default, and actually not document how to remove it. This would be the same behavior that we have currently implemented in the iOS SDK (per @1ec5) and be the most effective way to prevent users from unwillingly violating our TOS.

we have lines of communication open with all users that have approved white labeling (customer success) and so if they want info on how to remove the logo, we can provide it.

@mourner
Copy link
Member

mourner commented Jan 11, 2017

@mollymerp it seems to be implemented at the TileJSON level (with mapbox_logo property) — you would need to listen to map source.load event and check whether e.source.mapbox_logo is true.

@mollymerp
Copy link
Contributor Author

mollymerp commented Jan 11, 2017

~@mourner I think the mapbox_logo flag is only enabled for mapbox.js tilesets because I don't see it coming through in the tileJSON in mapbox-gl-js.~~(👈 that was incorrect) That flag automatically disables the logo for any enterprise accounts, which is not ideal because only a fraction of enterprise accounts actually have the rights to remove the logo from their maps.

Both the Android and iOS SDKs enable the Mapbox logo automatically for all users and I think it makes most sense to follow this pattern.

@andrewharvey
Copy link
Collaborator

@mollymerp Not required but might be a good idea to add aria-label="Mapbox logo" to that element for better accessibility support.

@mollymerp
Copy link
Contributor Author

@andrewharvey thank you so much for catching that! I'll have to get better about making a habit of including these.

@andrewharvey
Copy link
Collaborator

While technically not a breaking change, it will act as a breaking change for those who've followed the current advice and manually added the logo (as they'll end up with two overlapping logos, potentially slightly offset from each other). So a notice about this in the CHANGELOG when released will be welcome.

@lucaswoj
Copy link
Contributor

We are going to collaborate with the teams that maintain Mapbox's APIs to implement a mapbox_logo-like property before moving forward with this PR.

@mollymerp
Copy link
Contributor Author

mollymerp commented Jan 18, 2017

I think we should merge now. This would make Mapbox GL JS have parity with our mobile SDKs and prevent further accidental violations of our TOS. We can always go back later when the API response contains appropriate flags to indicate permissible white-labeling and configure the control that way.

@mollymerp
Copy link
Contributor Author

Ok I've updated this PR to rely on the mapbox_logo property returned in the TileJSON object. I'm also in the process of updating how that property is set by the APIs but this PR works independently of those changes.

cc @lucaswoj @jfirebaugh

@@ -100,7 +100,7 @@ const defaultOptions = {
* Keep in mind that these classes are used for controlling a style layer's paint properties, so are *not* reflected
* in an HTML element's `class` attribute. To learn more about Mapbox style classes, read about
* [Layers](https://www.mapbox.com/mapbox-gl-style-spec/#layers) in the style specification.
* @param {boolean} [options.attributionControl=true] If `true`, an [AttributionControl](#AttributionControl) will be added to the map.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you really mean to replace attributionControl with logoPosition, or did you mean to replace logoControl with logoPosition?

Given further down you've dropped out options.logoControl with options.logoPosition but retained options.attributionControl.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yipes good catch @andrewharvey -- this was not intentional!

@@ -47,6 +48,7 @@ const defaultOptions = {
hash: false,

attributionControl: true,
logoControl: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you missed updating this to logoPosition: 'bottom-left'. Or actually maybe you just need to remove as it's not used anywhere anymore from what I can see and the default is obtained from .getDefaultPosition() if the option is undefined anyway...

Copy link
Contributor

@jfirebaugh jfirebaugh left a comment

Choose a reason for hiding this comment

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

🚢 after a few small changes.

class LogoControl {

constructor() {
util.bindAll(['_logoRequired', '_updateLogo'], this);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: _logoRequired doesn't need to be bound (it's not used as an event handler).

}

onRemove() {
this._container.parentNode.removeChild(this._container);
Copy link
Contributor

Choose a reason for hiding this comment

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

Also needs this._map.off('data', this._updateLogo).

@mollymerp mollymerp dismissed mourner’s stale review January 27, 2017 21:08

addressed all comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Mapbox wordmark control
5 participants