Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
Resolve console warnings (#1329)
Browse files Browse the repository at this point in the history
* move warning about classic style deprecation while validating tileJSON

* fix getTileJSON not a functin error
  • Loading branch information
Rebecca Rice authored Apr 29, 2020
1 parent 1389dc0 commit 8e5b0aa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 2 additions & 6 deletions src/format_url.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

var config = require('./config'),
warn = require('./util').warn,
version = require('../package.json').version;

module.exports = function(path, accessToken) {
Expand Down Expand Up @@ -36,15 +35,12 @@ module.exports.tileJSON = function(urlOrMapID, accessToken) {
'L.mapbox.styleLayer, not L.mapbox.tileLayer');
}

if (urlOrMapID.indexOf('/') !== -1)
return urlOrMapID;
if (urlOrMapID.indexOf('/') !== -1) return urlOrMapID;

var url;
if (urlOrMapID in config.TEMPLATE_STYLES) {
url = module.exports('/styles/v1/' + config.TEMPLATE_STYLES[urlOrMapID], accessToken);
url = module.exports('/styles/v1/' + config.TEMPLATE_STYLES[urlOrMapID], accessToken);
} else {
warn('Warning: this implementation is loading a Mapbox Studio Classic style (' + urlOrMapID + '). ' +
'Studio Classic styles are scheduled for deprecation: https://blog.mapbox.com/deprecating-studio-classic-styles-c65a744140a6');
url = module.exports('/v4/' + urlOrMapID + '.json', accessToken);
}

Expand Down
6 changes: 5 additions & 1 deletion src/load_tilejson.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ var request = require('./request'),
module.exports = {
_loadTileJSON: function(_) {
if (typeof _ === 'string') {
var style = _;
_ = format_url.tileJSON(_, this.options && this.options.accessToken);
var isGLStyle = _.indexOf('/styles/v1/') !== -1;

if (!isGLStyle) {
util.warn('Warning: this implementation is loading a Mapbox Studio Classic style (' + style + '). ' +
'Studio Classic styles are scheduled for deprecation: https://blog.mapbox.com/deprecating-studio-classic-styles-c65a744140a6')
}
request(_, L.bind(function(err, json) {
if (err) {
util.log('could not load TileJSON at ' + _);
Expand Down
2 changes: 1 addition & 1 deletion src/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ var LMap = L.Map.extend({
// ensure logo appears even when mapbox layer added after map is initialized
var mapboxLogoControl = this._mapboxLogoControl.getContainer();
if (!L.DomUtil.hasClass(mapboxLogoControl, 'mapbox-logo-true')) {
var tileJSON = layer.getTileJSON();
var tileJSON = layer._tilejson;
this._mapboxLogoControl._setTileJSON(tileJSON);
}

Expand Down

0 comments on commit 8e5b0aa

Please sign in to comment.