Skip to content

Commit eb93b37

Browse files
committed
add VectorTileSource#setData for dynamic vector tiles rendering mapbox#3709
1 parent c605974 commit eb93b37

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/source/vector_tile_source.js

+17
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,23 @@ class VectorTileSource extends Evented implements Source {
9494
this.load();
9595
}
9696

97+
setData(options: VectorSourceSpecification & {collectResourceTiming: boolean}) {
98+
if (this._tileJSONRequest) {
99+
this._tileJSONRequest.cancel();
100+
}
101+
102+
extend(this, pick(options, ['url', 'scheme', 'tileSize']));
103+
this._options = extend({ type: 'vector' }, options);
104+
105+
this._collectResourceTiming = options.collectResourceTiming;
106+
107+
if (this.tileSize !== 512) {
108+
throw new Error('vector tile sources must have a tileSize of 512');
109+
}
110+
111+
this.load();
112+
}
113+
97114
onRemove() {
98115
if (this._tileJSONRequest) {
99116
this._tileJSONRequest.cancel();

0 commit comments

Comments
 (0)