Skip to content

Commit a2d2522

Browse files
committed
modernize createMapbox API
1 parent 5b43b8c commit a2d2522

File tree

3 files changed

+13
-20
lines changed

3 files changed

+13
-20
lines changed

src/plots/mapbox/index.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var Lib = require('../../lib');
1414
var getSubplotCalcData = require('../../plots/get_data').getSubplotCalcData;
1515
var xmlnsNamespaces = require('../../constants/xmlns_namespaces');
1616

17-
var createMapbox = require('./mapbox');
17+
var Mapbox = require('./mapbox');
1818

1919
var MAPBOX = 'mapbox';
2020

@@ -66,14 +66,7 @@ exports.plot = function plot(gd) {
6666
var mapbox = opts._subplot;
6767

6868
if(!mapbox) {
69-
mapbox = createMapbox({
70-
gd: gd,
71-
container: fullLayout._glcontainer.node(),
72-
id: id,
73-
fullLayout: fullLayout,
74-
staticPlot: gd._context.staticPlot
75-
});
76-
69+
mapbox = new Mapbox(gd, id);
7770
fullLayout[id]._subplot = mapbox;
7871
}
7972

src/plots/mapbox/layers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ proto.removeLayer = function() {
120120
}
121121
};
122122

123-
proto.dispose = function dispose() {
123+
proto.dispose = function() {
124124
var map = this.map;
125125
map.removeLayer(this.idLayer);
126126
map.removeSource(this.idSource);

src/plots/mapbox/mapbox.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ var constants = require('./constants');
2020
var layoutAttributes = require('./layout_attributes');
2121
var createMapboxLayer = require('./layers');
2222

23-
function Mapbox(opts) {
24-
this.id = opts.id;
25-
this.gd = opts.gd;
26-
this.container = opts.container;
27-
this.isStatic = opts.staticPlot;
23+
function Mapbox(gd, id) {
24+
this.id = id;
25+
this.gd = gd;
2826

29-
var fullLayout = opts.fullLayout;
27+
var fullLayout = gd._fullLayout;
28+
var context = gd._context;
29+
30+
this.container = fullLayout._glcontainer.node();
31+
this.isStatic = context.staticPlot;
3032

3133
// unique id for this Mapbox instance
3234
this.uid = fullLayout._uid + '-' + this.id;
@@ -47,10 +49,6 @@ function Mapbox(opts) {
4749

4850
var proto = Mapbox.prototype;
4951

50-
module.exports = function createMapbox(opts) {
51-
return new Mapbox(opts);
52-
};
53-
5452
proto.plot = function(calcData, fullLayout, promises) {
5553
var self = this;
5654
var opts = fullLayout[self.id];
@@ -570,3 +568,5 @@ function convertStyleVal(val) {
570568
function convertCenter(center) {
571569
return [center.lon, center.lat];
572570
}
571+
572+
module.exports = Mapbox;

0 commit comments

Comments
 (0)