Skip to content

Commit

Permalink
[feature] Add redraw function to map (#300)
Browse files Browse the repository at this point in the history
Resolves #206
  • Loading branch information
fredj authored Sep 3, 2021
1 parent 10a7f4b commit 04ff47d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- Migrated the production code to typescript
- ** Breaking Change ** removed `version` from the public API
- ** Breaking Change ** stopped supporting IE (internet explorer)
- Added redraw function to map (#206)
- *...Add new stuff here...*

### 🐞 Bug fixes
Expand Down
18 changes: 18 additions & 0 deletions src/ui/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2608,6 +2608,24 @@ class Map extends Camera {
return this;
}

/**
* Force a synchronous redraw of the map.
* @example
* map.redraw();
* @returns {Map} `this`
*/
redraw(): Map {
if (this.style) {
// cancel the scheduled update
if (this._frame) {
this._frame.cancel();
this._frame = null;
}
this._render(0);
}
return this;
}

/**
* Clean up and release all internal resources associated with this map.
*
Expand Down
10 changes: 10 additions & 0 deletions test/unit/ui/map.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,16 @@ test('Map', (t) => {
});
});

t.test('#redraw', (t) => {
const map = createMap(t);

map.once('idle', () => {
map.once('render', () => t.end());

map.redraw();
});
});

t.test('#addControl', (t) => {
const map = createMap(t);
const control = {
Expand Down

0 comments on commit 04ff47d

Please sign in to comment.