feat: Add a baseQuad option to tileLayers.
MODIFY
src/canvas/tileLayer.js
src/canvas/tileLayer.js
@@ -5,6 +5,7 @@ var canvas_tileLayer = function () {
var m_this = this,
s_init = this._init,
s_exit = this._exit,
+ s_update = this._update,
m_quadFeature,
m_nextTileId = 0,
m_tiles = [];
@@ -60,6 +61,18 @@ var canvas_tileLayer = function () {
}
};
+ /**
+ * Update layer.
+ *
+ * @param {object} request A value to pass to the parent class.
+ * @returns {this}
+ */
+ this._update = function (request) {
+ s_update.call(m_this, request);
+ m_this._addBaseQuadToTiles(m_quadFeature, m_tiles);
+ return m_this;
+ };
+
/**
* Clean up the layer.
*/

MODIFY
src/svg/tileLayer.js
src/svg/tileLayer.js
@@ -2,9 +2,11 @@ var registerLayerAdjustment = require('../registry').registerLayerAdjustment;
var svg_tileLayer = function () {
'use strict';
+
var m_this = this,
s_init = this._init,
s_exit = this._exit,
+ s_update = this._update,
m_quadFeature,
m_nextTileId = 0,
m_tiles = [];
@@ -60,6 +62,18 @@ var svg_tileLayer = function () {
}
};
+ /**
+ * Update layer.
+ *
+ * @param {object} request A value to pass to the parent class.
+ * @returns {this}
+ */
+ this._update = function (request) {
+ s_update.call(m_this, request);
+ m_this._addBaseQuadToTiles(m_quadFeature, m_tiles);
+ return m_this;
+ };
+
/**
* Clean up the layer.
*/

MODIFY
src/tileLayer.js
src/tileLayer.js
@@ -77,6 +77,10 @@ var featureLayer = require('./featureLayer');
* loaded. 'all' is when tiles in view and tiles that were once requested
* have been loaded (this corresponds to having all network activity
* finished).
+ * @property {object} [baseQuad] A quad feature element to draw before below
+ * any tile layers. If specified, this uses the quad defaults, so this is a
+ * ``geo.quadFeature.position`` object with, typically, an ``image`` property
+ * added to it. The quad positions are in the map gcs coordinates.
*/
/**
@@ -219,6 +223,7 @@ var tileLayer = function (arg) {
m_maxBounds = [],
m_reference,
m_exited,
+ m_lastBaseQuad,
m_this = this;
// copy the options into a private variable
@@ -1658,6 +1663,41 @@ var tileLayer = function (arg) {
return m_this;
};
+ /**
+ * Get/set the baseQuad.
+ *
+ * @property {object} [baseQuad] A quad feature element to draw before below
+ * any tile layers. If specified, this uses the quad defaults, so this is
+ * a ``geo.quadFeature.position`` object with, typically, an ``image``
+ * property added to it. The quad positions are in the map gcs
+ * coordinates.
+ * @name geo.tileLayer.baseQuad
+ */
+ Object.defineProperty(this, 'baseQuad', {
+ get: function () { return m_this._options.baseQuad; },
+ set: function (baseQuad) {
+ m_this._options.baseQuad = baseQuad;
+ m_this._update();
+ }
+ });
+
+ this._addBaseQuadToTiles = function (quadFeature, tiles) {
+ if (quadFeature) {
+ if (this.baseQuad !== m_lastBaseQuad) {
+ if (m_lastBaseQuad) {
+ tiles.splice(0, 1);
+ }
+ m_lastBaseQuad = this.baseQuad;
+ if (m_lastBaseQuad) {
+ tiles.splice(0, 0, this.baseQuad);
+ quadFeature.cacheUpdate(0);
+ }
+ quadFeature.data(tiles);
+ }
+ quadFeature._update();
+ }
+ };
+
/**
* Initialize after the layer is added to the map.
*

MODIFY
src/webgl/tileLayer.js
src/webgl/tileLayer.js
@@ -168,9 +168,7 @@ var webgl_tileLayer = function () {
*/
this._update = function (request) {
s_update.call(m_this, request);
- if (m_quadFeature) {
- m_quadFeature._update();
- }
+ m_this._addBaseQuadToTiles(m_quadFeature, m_tiles);
return m_this;
};

MODIFY
tests/cases/osmLayer.js
tests/cases/osmLayer.js
@@ -383,6 +383,14 @@ describe('geo.core.osmLayer', function () {
// function is called with eight parameters in some instances
return Object.keys(layer.activeTiles).length === 21;
});
+ it('baseQuad', function () {
+ expect(layer.baseQuad).toBe(undefined);
+ var quad = {ul: {x: 0, y: 0}, lr: {x: 10, y: 10}, image: '/testdata/white.jpg'};
+ layer.baseQuad = quad;
+ expect(layer.baseQuad).toBe(quad);
+ layer.baseQuad = undefined;
+ expect(layer.baseQuad).toBe(undefined);
+ });
it('destroy', destroy_map);
});

MODIFY
tests/cases/tileLayer.js
tests/cases/tileLayer.js
@@ -477,6 +477,14 @@ describe('geo.tileLayer', function () {
layer.reference = 'A';
expect(layer.reference).toBe(layer.id() + '_A');
});
+ it('baseQuad', function () {
+ var m = map(), layer;
+ opts.map = m;
+ layer = geo.tileLayer(opts);
+ expect(layer.baseQuad).toBe(undefined);
+ // we don't test setting it here, as we have too much mocked to carry
+ // through. The setting test is done in the osmLayer tests.
+ });
});
describe('Public utility methods', function () {
describe('isValid', function () {

feat: Add a baseQuad option to tileLayers.