diff --git a/js/ui/map.js b/js/ui/map.js index 04ab4f27d6e..a930c72be9f 100755 --- a/js/ui/map.js +++ b/js/ui/map.js @@ -346,6 +346,15 @@ class Map extends Camera { this.transform.resize(width, height); this.painter.resize(width, height); + const gl = this.painter.gl; + const maxSize = gl.getParameter(gl.MAX_RENDERBUFFER_SIZE) / 2; + if (this._canvas.width > maxSize || this._canvas.height > maxSize) { + util.warnOnce( + `Map is larger than maximum size supported by this system ` + + `(${maxSize}px by ${maxSize}px).` + ); + } + return this .fire('movestart') .fire('move') diff --git a/test/js/ui/map.test.js b/test/js/ui/map.test.js index 533263ca1fb..787d93ec0a0 100755 --- a/test/js/ui/map.test.js +++ b/test/js/ui/map.test.js @@ -62,6 +62,23 @@ test('Map', (t) => { container: 'anElementIdWhichDoesNotExistInTheDocument' }); }, new Error("Container 'anElementIdWhichDoesNotExistInTheDocument' not found"), 'throws on invalid map container id'); + + t.end(); + }); + + t.test('constructor, max size detection', (t) => { + t.stub(console, 'warn'); + + const container = window.document.createElement('div'); + container.offsetWidth = 10000; + container.offsetHeight = 10000; + new Map({container}); + + t.match( + console.warn.getCall(0).args[0], + /Map is larger than maximum size supported by this system \([0-9]+px by [0-9]+px\)./ + ); + t.end(); });