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 deprecation notice for paint classes #4038

Merged
merged 3 commits into from
Jan 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## master

#### Deprecation Notices
- [Style classes](https://www.mapbox.com/mapbox-gl-style-spec/#layer-paint.*) are deprecated and will be removed in an upcoming release of Mapbox GL JS.

## 0.31.0 (Jan 10 2017)

#### New Features
Expand Down
15 changes: 15 additions & 0 deletions js/ui/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,15 @@ class Map extends Camera {
* 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.
*
* **Note:** Style classes are deprecated and will be removed in an upcoming release of Mapbox GL JS.
*
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about adding a util.warnOnce to the body of these methods?

* @param {string} klass The style class to add.
* @param {StyleOptions} [options]
* @fires change
* @returns {Map} `this`
*/
addClass(klass, options) {
util.warnOnce('Style classes are deprecated and will be removed in an upcoming release of Mapbox GL JS.');
if (this._classes.indexOf(klass) >= 0 || klass === '') return this;
this._classes.push(klass);
this._classOptions = options;
Expand All @@ -273,12 +276,15 @@ class Map extends Camera {
/**
* Removes a Mapbox style class from the map.
*
* **Note:** Style classes are deprecated and will be removed in an upcoming release of Mapbox GL JS.
*
* @param {string} klass The style class to remove.
* @param {StyleOptions} [options]
* @fires change
* @returns {Map} `this`
*/
removeClass(klass, options) {
util.warnOnce('Style classes are deprecated and will be removed in an upcoming release of Mapbox GL JS.');
const i = this._classes.indexOf(klass);
if (i < 0 || klass === '') return this;
this._classes.splice(i, 1);
Expand All @@ -291,12 +297,15 @@ class Map extends Camera {
/**
* Replaces the map's existing Mapbox style classes with a new array of classes.
*
* **Note:** Style classes are deprecated and will be removed in an upcoming release of Mapbox GL JS.
*
* @param {Array<string>} klasses The style classes to set.
* @param {StyleOptions} [options]
* @fires change
* @returns {Map} `this`
*/
setClasses(klasses, options) {
util.warnOnce('Style classes are deprecated and will be removed in an upcoming release of Mapbox GL JS.');
const uniqueClasses = {};
for (let i = 0; i < klasses.length; i++) {
if (klasses[i] !== '') uniqueClasses[klasses[i]] = true;
Expand All @@ -312,19 +321,25 @@ class Map extends Camera {
* Returns a Boolean indicating whether the map has the
* specified Mapbox style class.
*
* **Note:** Style classes are deprecated and will be removed in an upcoming release of Mapbox GL JS.
*
* @param {string} klass The style class to test.
* @returns {boolean} `true` if the map has the specified style class.
*/
hasClass(klass) {
util.warnOnce('Style classes are deprecated and will be removed in an upcoming release of Mapbox GL JS.');
return this._classes.indexOf(klass) >= 0;
}

/**
* Returns the map's Mapbox style classes.
*
* **Note:** Style classes are deprecated and will be removed in an upcoming release of Mapbox GL JS.
*
* @returns {Array<string>} The map's style classes.
*/
getClasses() {
util.warnOnce('Style classes are deprecated and will be removed in an upcoming release of Mapbox GL JS.');
return this._classes;
}

Expand Down