maputnik/src/style.js

28 lines
449 B
JavaScript
Raw Normal View History

2016-09-08 21:42:18 +02:00
import React from 'react';
// A wrapper around Mapbox GL style
export class Style {
constructor() {
this.styleHistory = [];
this.renderers = [];
2016-09-08 21:42:18 +02:00
}
load(style) {
this.currentStyle = style;
2016-09-08 21:42:18 +02:00
}
onRender(cb) {
this.renderers.push(cb);
2016-09-08 21:42:18 +02:00
}
update(style) {
this.styleHistory.push(this.currentStyle);
this.currentStyle = style;
this.renderers.forEach(r => r(this.currentStyle))
2016-09-08 21:42:18 +02:00
}
layers() {
return this.currentStyle.layers;
2016-09-08 21:42:18 +02:00
}
}