Skip to content

Commit

Permalink
GoogleMapsOverlay: requestRedraw when removing interleaved overlay (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
felixpalmer authored and Pessimistress committed May 22, 2023
1 parent 0d71f75 commit 9c85a9e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
6 changes: 5 additions & 1 deletion modules/google-maps/src/google-maps-overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,17 @@ export default class GoogleMapsOverlay {
if (map === this._map) {
return;
}

const {VECTOR, UNINITIALIZED} = google.maps.RenderingType;
if (this._map) {
if (!map && this._map.getRenderingType() === VECTOR && this.props.interleaved) {
(this._overlay as google.maps.WebGLOverlayView).requestRedraw();
}
this._overlay?.setMap(null);
this._map = null;
}
if (map) {
this._map = map;
const {UNINITIALIZED} = google.maps.RenderingType;
const renderingType = map.getRenderingType();
if (renderingType !== UNINITIALIZED) {
this._createOverlay(map);
Expand Down
9 changes: 9 additions & 0 deletions test/modules/google-maps/google-maps-overlay.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ for (const interleaved of [true, false]) {
t.ok(overlay._overlay.onContextRestored, 'onContextRestored lifecycle function is registered');
t.ok(overlay._overlay.onDraw, 'onDraw lifecycle function is registered');
t.ok(overlay._overlay.onRemove, 'onRemove lifecycle function is registered');

t.notOk(overlay._overlay._draws, 'Map not yet drawn');
overlay.setMap(null);
if (interleaved) {
t.ok(overlay._overlay._draws, 'Redraw requested when map removed');
} else {
t.notOk(overlay._overlay._draws, 'Redraw not requested when map removed');
}

overlay.finalize();

t.end();
Expand Down
5 changes: 5 additions & 0 deletions test/modules/google-maps/mock-maps-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ export class WebGLOverlayView {
constructor() {
this.map = null;
this._container = document.createElement('div');
this._draws = 0;
}

setMap(map) {
Expand All @@ -217,4 +218,8 @@ export class WebGLOverlayView {
getDiv: () => this._container
};
}

requestRedraw() {
this._draws++;
}
}

0 comments on commit 9c85a9e

Please sign in to comment.