Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear quads on layer addition and removal. #1010

Merged
merged 3 commits into from
Jul 10, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions src/webgl/tileLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ var tileLayer = require('../tileLayer');

var webgl_tileLayer = function () {
'use strict';

var geo_event = require('../event');

var m_this = this,
s_init = this._init,
s_exit = this._exit,
Expand Down Expand Up @@ -132,16 +135,28 @@ var webgl_tileLayer = function () {
*/
this.zIndex = function (zIndex, allowDuplicate) {
if (zIndex !== undefined) {
/* If the z-index has changed, clear the quads so they are composited in
* the correct order. */
m_this.clear();
if (m_quadFeature) {
m_quadFeature.modified();
}
this._clearQuads(true);
}
return s_zIndex.apply(m_this, arguments);
};

/**
* If the z-index has changed or layers are added or removed, clear the quads
* so they are composited in the correct order.
*
* @param {boolean} [noredraw] If truthy, don't redraw after clearing the
* quads.
*/
this._clearQuads = function (noredraw) {
m_this.clear();
if (m_quadFeature) {
m_quadFeature.modified();
}
if (noredraw !== true) {
this.draw();
}
};

/**
* Update layer.
*
Expand Down Expand Up @@ -197,6 +212,10 @@ var webgl_tileLayer = function () {
m_quadFeature.gcs(m_this._options.gcs || m_this.map().gcs());
m_quadFeature.data(m_tiles);
m_quadFeature._update();

var map = m_this.map();
map.geoOn(geo_event.layerAdd, this._clearQuads);
map.geoOn(geo_event.layerRemove, this._clearQuads);
};

/* These functions don't need to do anything. */
Expand Down