Compare commits
19 Commits
v6.0.0-bet
...
v6.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0e5c4b7fe | ||
|
|
189ad24528 | ||
|
|
4aa11ecc94 | ||
|
|
e61c5c07bc | ||
|
|
0212ce6554 | ||
|
|
b76a0379dd | ||
|
|
e94c7b6c39 | ||
|
|
2c69ad2bb4 | ||
|
|
e8e7c46463 | ||
|
|
abda7f4f1d | ||
|
|
e8500c395c | ||
|
|
6f5a066bab | ||
|
|
08816ec9f9 | ||
|
|
fac659fa0a | ||
|
|
b0069c3c5d | ||
|
|
e7be28d2b5 | ||
|
|
15aa5ebc1f | ||
|
|
94edf32540 | ||
|
|
91d2f98774 |
@@ -236,3 +236,7 @@ A `WebGLArrayBuffer` must either be of type `ELEMENT_ARRAY_BUFFER` or `ARRAY_BUF
|
|||||||
### 63
|
### 63
|
||||||
|
|
||||||
Support for the `OES_element_index_uint` WebGL extension is mandatory for WebGL layers.
|
Support for the `OES_element_index_uint` WebGL extension is mandatory for WebGL layers.
|
||||||
|
|
||||||
|
### 64
|
||||||
|
|
||||||
|
Layer opacity must be a number.
|
||||||
|
|||||||
86
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ol",
|
"name": "ol",
|
||||||
"version": "6.0.0-beta.13",
|
"version": "6.0.0-beta.14",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -6571,9 +6571,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"karma-chrome-launcher": {
|
"karma-chrome-launcher": {
|
||||||
"version": "3.0.0",
|
"version": "3.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-3.1.0.tgz",
|
||||||
"integrity": "sha512-u/PnVgDOP97AUe/gJeABlC6Wa6aQ83MZsm0JgsJQ5bGQ9XcXON/7b2aRhl59A62Zom+q3PFveBkczc7E1RT7TA==",
|
"integrity": "sha512-3dPs/n7vgz1rxxtynpzZTvb9y/GIaW8xjAwcIGttLbycqoFtI7yo1NGnQi6oFTherRE+GIhCAHZC4vEqWGhNvg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"which": "^1.2.1"
|
"which": "^1.2.1"
|
||||||
@@ -6766,9 +6766,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"lodash": {
|
"lodash": {
|
||||||
"version": "4.17.11",
|
"version": "4.17.15",
|
||||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz",
|
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
|
||||||
"integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==",
|
"integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"log-driver": {
|
"log-driver": {
|
||||||
@@ -7219,9 +7219,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mixin-deep": {
|
"mixin-deep": {
|
||||||
"version": "1.3.1",
|
"version": "1.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz",
|
||||||
"integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==",
|
"integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"for-in": "^1.0.2",
|
"for-in": "^1.0.2",
|
||||||
@@ -8837,13 +8837,20 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rollup-pluginutils": {
|
"rollup-pluginutils": {
|
||||||
"version": "2.7.0",
|
"version": "2.8.1",
|
||||||
"resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.1.tgz",
|
||||||
"integrity": "sha512-FoP6L1YnMYTAR06Dpq5LE3jJtMwPE6H4VEOqFU23yoziZnqNRSiWcVy6YgEY5PdQB4G7278+8c4TvB0JKS1csA==",
|
"integrity": "sha512-J5oAoysWar6GuZo0s+3bZ6sVZAC0pfqKz68De7ZgDi5z63jOVZn1uJL/+z1jeKHNbGII8kAyHF5q8LnxSX5lQg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"estree-walker": "^0.6.0",
|
"estree-walker": "^0.6.1"
|
||||||
"micromatch": "^3.1.10"
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"estree-walker": {
|
||||||
|
"version": "0.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz",
|
||||||
|
"integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"run-async": {
|
"run-async": {
|
||||||
@@ -9133,9 +9140,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"set-value": {
|
"set-value": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz",
|
||||||
"integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==",
|
"integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"extend-shallow": "^2.0.1",
|
"extend-shallow": "^2.0.1",
|
||||||
@@ -10245,38 +10252,15 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"union-value": {
|
"union-value": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz",
|
||||||
"integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=",
|
"integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"arr-union": "^3.1.0",
|
"arr-union": "^3.1.0",
|
||||||
"get-value": "^2.0.6",
|
"get-value": "^2.0.6",
|
||||||
"is-extendable": "^0.1.1",
|
"is-extendable": "^0.1.1",
|
||||||
"set-value": "^0.4.3"
|
"set-value": "^2.0.1"
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"extend-shallow": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
|
|
||||||
"integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"is-extendable": "^0.1.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"set-value": {
|
|
||||||
"version": "0.4.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz",
|
|
||||||
"integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"extend-shallow": "^2.0.1",
|
|
||||||
"is-extendable": "^0.1.1",
|
|
||||||
"is-plain-object": "^2.0.1",
|
|
||||||
"to-object-path": "^0.3.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"unique-filename": {
|
"unique-filename": {
|
||||||
@@ -10562,9 +10546,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"webpack": {
|
"webpack": {
|
||||||
"version": "4.39.1",
|
"version": "4.39.2",
|
||||||
"resolved": "https://registry.npmjs.org/webpack/-/webpack-4.39.1.tgz",
|
"resolved": "https://registry.npmjs.org/webpack/-/webpack-4.39.2.tgz",
|
||||||
"integrity": "sha512-/LAb2TJ2z+eVwisldp3dqTEoNhzp/TLCZlmZm3GGGAlnfIWDgOEE758j/9atklNLfRyhKbZTCOIoPqLJXeBLbQ==",
|
"integrity": "sha512-AKgTfz3xPSsEibH00JfZ9sHXGUwIQ6eZ9tLN8+VLzachk1Cw2LVmy+4R7ZiwTa9cZZ15tzySjeMui/UnSCAZhA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@webassemblyjs/ast": "1.8.5",
|
"@webassemblyjs/ast": "1.8.5",
|
||||||
@@ -10593,9 +10577,9 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"acorn": {
|
"acorn": {
|
||||||
"version": "6.2.1",
|
"version": "6.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.3.0.tgz",
|
||||||
"integrity": "sha512-JD0xT5FCRDNyjDda3Lrg/IxFscp9q4tiYtxE1/nOzlKCk7hIRuYjhq1kCNkbPjMRMZuFq20HNQn1I9k8Oj0E+Q==",
|
"integrity": "sha512-/czfa8BwS88b9gWQVhc8eknunSA2DoJpJyTQkhheIf5E48u1N0R4q/YxxsAeqRrmK9TQ/uYfgLDfZo91UlANIA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"ajv": {
|
"ajv": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ol",
|
"name": "ol",
|
||||||
"version": "6.0.0-beta.13",
|
"version": "6.0.0-beta.14",
|
||||||
"description": "OpenLayers mapping library",
|
"description": "OpenLayers mapping library",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"map",
|
"map",
|
||||||
@@ -70,7 +70,7 @@
|
|||||||
"jsdoc": "3.6.3",
|
"jsdoc": "3.6.3",
|
||||||
"jsdoc-plugin-typescript": "^2.0.1",
|
"jsdoc-plugin-typescript": "^2.0.1",
|
||||||
"karma": "^4.1.0",
|
"karma": "^4.1.0",
|
||||||
"karma-chrome-launcher": "3.0.0",
|
"karma-chrome-launcher": "3.1.0",
|
||||||
"karma-coverage": "^1.1.2",
|
"karma-coverage": "^1.1.2",
|
||||||
"karma-coverage-istanbul-reporter": "^2.0.5",
|
"karma-coverage-istanbul-reporter": "^2.0.5",
|
||||||
"karma-firefox-launcher": "^1.1.0",
|
"karma-firefox-launcher": "^1.1.0",
|
||||||
@@ -97,7 +97,7 @@
|
|||||||
"typescript": "^3.4.5",
|
"typescript": "^3.4.5",
|
||||||
"url-polyfill": "^1.1.5",
|
"url-polyfill": "^1.1.5",
|
||||||
"walk": "^2.3.9",
|
"walk": "^2.3.9",
|
||||||
"webpack": "4.39.1",
|
"webpack": "4.39.2",
|
||||||
"webpack-cli": "^3.3.2",
|
"webpack-cli": "^3.3.2",
|
||||||
"webpack-dev-middleware": "^3.6.2",
|
"webpack-dev-middleware": "^3.6.2",
|
||||||
"webpack-dev-server": "^3.3.1",
|
"webpack-dev-server": "^3.3.1",
|
||||||
|
|||||||
BIN
rendering/cases/layer-tile-render-listener/expected.png
Normal file
|
After Width: | Height: | Size: 118 KiB |
46
rendering/cases/layer-tile-render-listener/main.js
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
import Map from '../../../src/ol/Map.js';
|
||||||
|
import View from '../../../src/ol/View.js';
|
||||||
|
import TileLayer from '../../../src/ol/layer/Tile.js';
|
||||||
|
import {transform, fromLonLat} from '../../../src/ol/proj.js';
|
||||||
|
import XYZ from '../../../src/ol/source/XYZ.js';
|
||||||
|
import CircleStyle from '../../../src/ol/style/Circle.js';
|
||||||
|
import Fill from '../../../src/ol/style/Fill.js';
|
||||||
|
import Stroke from '../../../src/ol/style/Stroke.js';
|
||||||
|
import Point from '../../../src/ol/geom/Point.js';
|
||||||
|
import {getVectorContext} from '../../../src/ol/render.js';
|
||||||
|
|
||||||
|
const center = fromLonLat([8.6, 50.1]);
|
||||||
|
|
||||||
|
const layer = new TileLayer({
|
||||||
|
source: new XYZ({
|
||||||
|
url: '/data/tiles/satellite/{z}/{x}/{y}.jpg',
|
||||||
|
transition: 0
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
const onRender = function(event) {
|
||||||
|
const context = event.context;
|
||||||
|
context.restore();
|
||||||
|
const vectorContext = getVectorContext(event);
|
||||||
|
vectorContext.setImageStyle(new CircleStyle({
|
||||||
|
radius: 12,
|
||||||
|
fill: new Fill({color: 'yellow'}),
|
||||||
|
stroke: new Stroke({color: 'red', width: 1})
|
||||||
|
}));
|
||||||
|
vectorContext.drawPoint(new Point(
|
||||||
|
transform([13, 37], 'EPSG:4326', 'EPSG:3857')));
|
||||||
|
};
|
||||||
|
layer.on('postrender', onRender);
|
||||||
|
|
||||||
|
const map = new Map({
|
||||||
|
layers: [
|
||||||
|
],
|
||||||
|
target: 'map',
|
||||||
|
view: new View({
|
||||||
|
center: center,
|
||||||
|
zoom: 3
|
||||||
|
})
|
||||||
|
});
|
||||||
|
map.addLayer(layer);
|
||||||
|
|
||||||
|
render();
|
||||||
@@ -6,6 +6,7 @@ import BaseObject from '../Object.js';
|
|||||||
import LayerProperty from './Property.js';
|
import LayerProperty from './Property.js';
|
||||||
import {clamp} from '../math.js';
|
import {clamp} from '../math.js';
|
||||||
import {assign} from '../obj.js';
|
import {assign} from '../obj.js';
|
||||||
|
import {assert} from '../asserts.js';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,8 +53,11 @@ class BaseLayer extends BaseObject {
|
|||||||
* @type {Object<string, *>}
|
* @type {Object<string, *>}
|
||||||
*/
|
*/
|
||||||
const properties = assign({}, options);
|
const properties = assign({}, options);
|
||||||
|
|
||||||
properties[LayerProperty.OPACITY] =
|
properties[LayerProperty.OPACITY] =
|
||||||
options.opacity !== undefined ? options.opacity : 1;
|
options.opacity !== undefined ? options.opacity : 1;
|
||||||
|
assert(typeof properties[LayerProperty.OPACITY] === 'number', 64); // Layer opacity must be a number
|
||||||
|
|
||||||
properties[LayerProperty.VISIBLE] =
|
properties[LayerProperty.VISIBLE] =
|
||||||
options.visible !== undefined ? options.visible : true;
|
options.visible !== undefined ? options.visible : true;
|
||||||
properties[LayerProperty.Z_INDEX] = options.zIndex;
|
properties[LayerProperty.Z_INDEX] = options.zIndex;
|
||||||
@@ -292,6 +296,7 @@ class BaseLayer extends BaseObject {
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
setOpacity(opacity) {
|
setOpacity(opacity) {
|
||||||
|
assert(typeof opacity === 'number', 64); // Layer opacity must be a number
|
||||||
this.set(LayerProperty.OPACITY, opacity);
|
this.set(LayerProperty.OPACITY, opacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -377,7 +377,8 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const uid = getUid(this);
|
const uid = getUid(this);
|
||||||
const alpha = opacity * (transition ? tile.getAlpha(uid, frameState.time) : 1);
|
const tileAlpha = transition ? tile.getAlpha(uid, frameState.time) : 1;
|
||||||
|
const alpha = opacity * tileAlpha;
|
||||||
const alphaChanged = alpha !== this.context.globalAlpha;
|
const alphaChanged = alpha !== this.context.globalAlpha;
|
||||||
if (alphaChanged) {
|
if (alphaChanged) {
|
||||||
this.context.save();
|
this.context.save();
|
||||||
@@ -389,7 +390,7 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer {
|
|||||||
if (alphaChanged) {
|
if (alphaChanged) {
|
||||||
this.context.restore();
|
this.context.restore();
|
||||||
}
|
}
|
||||||
if (alpha !== 1) {
|
if (tileAlpha !== 1) {
|
||||||
frameState.animate = true;
|
frameState.animate = true;
|
||||||
} else if (transition) {
|
} else if (transition) {
|
||||||
tile.endTransition(uid);
|
tile.endTransition(uid);
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ class VectorTile extends UrlTile {
|
|||||||
* @private
|
* @private
|
||||||
* @type {Object<string, import("../VectorTile.js").default>}
|
* @type {Object<string, import("../VectorTile.js").default>}
|
||||||
*/
|
*/
|
||||||
this.sourceTiles_ = {};
|
this.sourceTileByCoordKey_ = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -173,7 +173,7 @@ class VectorTile extends UrlTile {
|
|||||||
*/
|
*/
|
||||||
clear() {
|
clear() {
|
||||||
this.tileCache.clear();
|
this.tileCache.clear();
|
||||||
this.sourceTiles_ = {};
|
this.sourceTileByCoordKey_ = {};
|
||||||
this.sourceTilesByTileKey_ = {};
|
this.sourceTilesByTileKey_ = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,7 +199,7 @@ class VectorTile extends UrlTile {
|
|||||||
const sourceZ = sourceTileGrid.getZForResolution(resolution, 1);
|
const sourceZ = sourceTileGrid.getZForResolution(resolution, 1);
|
||||||
const minZoom = sourceTileGrid.getMinZoom();
|
const minZoom = sourceTileGrid.getMinZoom();
|
||||||
|
|
||||||
const previousSourceTiles = this.sourceTilesByTileKey_[getKey(tile.tileCoord)];
|
const previousSourceTiles = this.sourceTilesByTileKey_[tile.getKey()];
|
||||||
if (previousSourceTiles && previousSourceTiles.length > 0 && previousSourceTiles[0].tileCoord[0] === sourceZ) {
|
if (previousSourceTiles && previousSourceTiles.length > 0 && previousSourceTiles[0].tileCoord[0] === sourceZ) {
|
||||||
return previousSourceTiles;
|
return previousSourceTiles;
|
||||||
}
|
}
|
||||||
@@ -212,10 +212,10 @@ class VectorTile extends UrlTile {
|
|||||||
covered = true;
|
covered = true;
|
||||||
empty = true;
|
empty = true;
|
||||||
sourceTileGrid.forEachTileCoord(extent, loadedZ, function(sourceTileCoord) {
|
sourceTileGrid.forEachTileCoord(extent, loadedZ, function(sourceTileCoord) {
|
||||||
const tileKey = getKey(sourceTileCoord);
|
const coordKey = getKey(sourceTileCoord);
|
||||||
let sourceTile;
|
let sourceTile;
|
||||||
if (tileKey in this.sourceTiles_) {
|
if (coordKey in this.sourceTileByCoordKey_) {
|
||||||
sourceTile = this.sourceTiles_[tileKey];
|
sourceTile = this.sourceTileByCoordKey_[coordKey];
|
||||||
const state = sourceTile.getState();
|
const state = sourceTile.getState();
|
||||||
if (state === TileState.LOADED || state === TileState.ERROR || state === TileState.EMPTY) {
|
if (state === TileState.LOADED || state === TileState.ERROR || state === TileState.EMPTY) {
|
||||||
empty = empty && state === TileState.EMPTY;
|
empty = empty && state === TileState.EMPTY;
|
||||||
@@ -230,7 +230,7 @@ class VectorTile extends UrlTile {
|
|||||||
sourceTile.extent = sourceTileGrid.getTileCoordExtent(sourceTileCoord);
|
sourceTile.extent = sourceTileGrid.getTileCoordExtent(sourceTileCoord);
|
||||||
sourceTile.projection = projection;
|
sourceTile.projection = projection;
|
||||||
sourceTile.resolution = sourceTileGrid.getResolution(sourceTileCoord[0]);
|
sourceTile.resolution = sourceTileGrid.getResolution(sourceTileCoord[0]);
|
||||||
this.sourceTiles_[tileKey] = sourceTile;
|
this.sourceTileByCoordKey_[coordKey] = sourceTile;
|
||||||
empty = false;
|
empty = false;
|
||||||
listen(sourceTile, EventType.CHANGE, this.handleTileChange, this);
|
listen(sourceTile, EventType.CHANGE, this.handleTileChange, this);
|
||||||
sourceTile.load();
|
sourceTile.load();
|
||||||
@@ -246,7 +246,7 @@ class VectorTile extends UrlTile {
|
|||||||
tile.loadingSourceTiles++;
|
tile.loadingSourceTiles++;
|
||||||
const key = listen(sourceTile, EventType.CHANGE, function() {
|
const key = listen(sourceTile, EventType.CHANGE, function() {
|
||||||
const state = sourceTile.getState();
|
const state = sourceTile.getState();
|
||||||
const sourceTileKey = getKey(sourceTile.tileCoord);
|
const sourceTileKey = sourceTile.getKey();
|
||||||
if (state === TileState.LOADED || state === TileState.ERROR) {
|
if (state === TileState.LOADED || state === TileState.ERROR) {
|
||||||
if (state === TileState.LOADED) {
|
if (state === TileState.LOADED) {
|
||||||
unlistenByKey(key);
|
unlistenByKey(key);
|
||||||
@@ -289,7 +289,7 @@ class VectorTile extends UrlTile {
|
|||||||
* @param {Array<import("../VectorTile").default>} sourceTiles Source tiles.
|
* @param {Array<import("../VectorTile").default>} sourceTiles Source tiles.
|
||||||
*/
|
*/
|
||||||
addSourceTiles(tile, sourceTiles) {
|
addSourceTiles(tile, sourceTiles) {
|
||||||
this.sourceTilesByTileKey_[getKey(tile.tileCoord)] = sourceTiles;
|
this.sourceTilesByTileKey_[tile.getKey()] = sourceTiles;
|
||||||
for (let i = 0, ii = sourceTiles.length; i < ii; ++i) {
|
for (let i = 0, ii = sourceTiles.length; i < ii; ++i) {
|
||||||
sourceTiles[i].consumers++;
|
sourceTiles[i].consumers++;
|
||||||
}
|
}
|
||||||
@@ -299,7 +299,7 @@ class VectorTile extends UrlTile {
|
|||||||
* @param {VectorRenderTile} tile Tile.
|
* @param {VectorRenderTile} tile Tile.
|
||||||
*/
|
*/
|
||||||
removeSourceTiles(tile) {
|
removeSourceTiles(tile) {
|
||||||
const tileKey = getKey(tile.tileCoord);
|
const tileKey = tile.getKey();
|
||||||
if (tileKey in this.sourceTilesByTileKey_) {
|
if (tileKey in this.sourceTilesByTileKey_) {
|
||||||
const sourceTiles = this.sourceTilesByTileKey_[tileKey];
|
const sourceTiles = this.sourceTilesByTileKey_[tileKey];
|
||||||
for (let i = 0, ii = sourceTiles.length; i < ii; ++i) {
|
for (let i = 0, ii = sourceTiles.length; i < ii; ++i) {
|
||||||
@@ -307,7 +307,7 @@ class VectorTile extends UrlTile {
|
|||||||
sourceTile.consumers--;
|
sourceTile.consumers--;
|
||||||
if (sourceTile.consumers === 0) {
|
if (sourceTile.consumers === 0) {
|
||||||
sourceTile.dispose();
|
sourceTile.dispose();
|
||||||
delete this.sourceTiles_[getKey(sourceTile.tileCoord)];
|
delete this.sourceTileByCoordKey_[getKey(sourceTile.tileCoord)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -318,11 +318,11 @@ class VectorTile extends UrlTile {
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
getTile(z, x, y, pixelRatio, projection) {
|
getTile(z, x, y, pixelRatio, projection) {
|
||||||
const tileCoordKey = getKeyZXY(z, x, y);
|
const coordKey = getKeyZXY(z, x, y);
|
||||||
const key = this.getKey();
|
const key = this.getKey();
|
||||||
let tile;
|
let tile;
|
||||||
if (this.tileCache.containsKey(tileCoordKey)) {
|
if (this.tileCache.containsKey(coordKey)) {
|
||||||
tile = /** @type {!import("../Tile.js").default} */ (this.tileCache.get(tileCoordKey));
|
tile = /** @type {!import("../Tile.js").default} */ (this.tileCache.get(coordKey));
|
||||||
if (tile.key === key) {
|
if (tile.key === key) {
|
||||||
return tile;
|
return tile;
|
||||||
}
|
}
|
||||||
@@ -352,9 +352,9 @@ class VectorTile extends UrlTile {
|
|||||||
if (tile) {
|
if (tile) {
|
||||||
newTile.interimTile = tile;
|
newTile.interimTile = tile;
|
||||||
newTile.refreshInterimChain();
|
newTile.refreshInterimChain();
|
||||||
this.tileCache.replace(tileCoordKey, newTile);
|
this.tileCache.replace(coordKey, newTile);
|
||||||
} else {
|
} else {
|
||||||
this.tileCache.set(tileCoordKey, newTile);
|
this.tileCache.set(coordKey, newTile);
|
||||||
}
|
}
|
||||||
return newTile;
|
return newTile;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
|
||||||
|
|
||||||
<svg
|
|
||||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
|
||||||
xmlns:cc="http://creativecommons.org/ns#"
|
|
||||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
||||||
xmlns:svg="http://www.w3.org/2000/svg"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
|
||||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
|
||||||
version="1.1"
|
|
||||||
id="Layer_1"
|
|
||||||
x="0px"
|
|
||||||
y="0px"
|
|
||||||
width="512px"
|
|
||||||
height="512px"
|
|
||||||
viewBox="0 0 512 512"
|
|
||||||
enable-background="new 0 0 512 512"
|
|
||||||
xml:space="preserve"
|
|
||||||
inkscape:version="0.48.4 r9939"
|
|
||||||
sodipodi:docname="me0.svg"><metadata
|
|
||||||
id="metadata3776"><rdf:RDF><cc:Work
|
|
||||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
|
||||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
|
||||||
id="defs3774" /><sodipodi:namedview
|
|
||||||
pagecolor="#ffffff"
|
|
||||||
bordercolor="#666666"
|
|
||||||
borderopacity="1"
|
|
||||||
objecttolerance="10"
|
|
||||||
gridtolerance="10"
|
|
||||||
guidetolerance="10"
|
|
||||||
inkscape:pageopacity="0"
|
|
||||||
inkscape:pageshadow="2"
|
|
||||||
inkscape:window-width="1024"
|
|
||||||
inkscape:window-height="1258"
|
|
||||||
id="namedview3772"
|
|
||||||
showgrid="false"
|
|
||||||
inkscape:zoom="0.4609375"
|
|
||||||
inkscape:cx="309.13338"
|
|
||||||
inkscape:cy="256"
|
|
||||||
inkscape:window-x="1016"
|
|
||||||
inkscape:window-y="-8"
|
|
||||||
inkscape:window-maximized="1"
|
|
||||||
inkscape:current-layer="Layer_1" />
|
|
||||||
|
|
||||||
<g
|
|
||||||
id="g3754"
|
|
||||||
style="fill:#085095;fill-opacity:1;stroke:#ffffff;stroke-opacity:1;stroke-width:25;stroke-miterlimit:4;stroke-dasharray:none;stroke-linejoin:round;stroke-linecap:round"><path
|
|
||||||
style="stroke:#ffffff;stroke-width:25;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;fill:#085095;fill-opacity:1;stroke-linejoin:round;stroke-linecap:round"
|
|
||||||
id="path3770"
|
|
||||||
d="m 256,25.6 c -95.4279,0 -172.8,77.3721 -172.8,172.8 0,95.4279 144,288 172.8,288 28.8,0 172.8,-192.5721 172.8,-288 C 428.8,102.9721 351.4279,25.6 256,25.6 z m 0,288 c -63.5346,0 -115.2,-51.6942 -115.2,-115.2 0,-63.5058 51.6654,-115.2 115.2,-115.2 63.5346,0 115.2,51.6942 115.2,115.2 0,63.5058 -51.6654,115.2 -115.2,115.2 z"
|
|
||||||
inkscape:connector-curvature="0" /><polygon
|
|
||||||
style="fill:#085095;stroke:#ffffff;stroke-width:69.44444444;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;fill-opacity:1"
|
|
||||||
transform="matrix(0.36,0,0,0.36,160.72934,103.79972)"
|
|
||||||
id="polygon3"
|
|
||||||
points="374.185,309.08 401.33,467.31 259.216,392.612 117.104,467.31 144.25,309.08 29.274,197.007 188.165,173.919 259.216,29.942 330.27,173.919 489.16,197.007 "
|
|
||||||
stroke-miterlimit="10" /></g></svg>
|
|
||||||
|
Before Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 6.7 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 9.0 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 9.5 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 806 B |
|
Before Width: | Height: | Size: 806 B |
|
Before Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 254 B |
|
Before Width: | Height: | Size: 392 B |
|
Before Width: | Height: | Size: 341 B |
|
Before Width: | Height: | Size: 504 B |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 7.3 KiB |
|
Before Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 6.6 KiB |
@@ -1,100 +0,0 @@
|
|||||||
import Map from '../../../../src/ol/Map.js';
|
|
||||||
import View from '../../../../src/ol/View.js';
|
|
||||||
import Point from '../../../../src/ol/geom/Point.js';
|
|
||||||
import TileLayer from '../../../../src/ol/layer/Tile.js';
|
|
||||||
import {assign} from '../../../../src/ol/obj.js';
|
|
||||||
import {transform} from '../../../../src/ol/proj.js';
|
|
||||||
import XYZ from '../../../../src/ol/source/XYZ.js';
|
|
||||||
import CircleStyle from '../../../../src/ol/style/Circle.js';
|
|
||||||
import Fill from '../../../../src/ol/style/Fill.js';
|
|
||||||
import Stroke from '../../../../src/ol/style/Stroke.js';
|
|
||||||
|
|
||||||
describe('ol.rendering.layer.Tile', function() {
|
|
||||||
|
|
||||||
let map;
|
|
||||||
|
|
||||||
function createMap(renderer, opt_center, opt_size, opt_pixelRatio, opt_resolutions) {
|
|
||||||
const MapConstructor = Map;
|
|
||||||
const size = opt_size !== undefined ? opt_size : [50, 50];
|
|
||||||
|
|
||||||
map = new MapConstructor({
|
|
||||||
pixelRatio: opt_pixelRatio || 1,
|
|
||||||
target: createMapDiv(size[0], size[1]),
|
|
||||||
view: new View({
|
|
||||||
center: opt_center !== undefined ? opt_center : transform(
|
|
||||||
[-122.416667, 37.783333], 'EPSG:4326', 'EPSG:3857'),
|
|
||||||
resolutions: opt_resolutions,
|
|
||||||
zoom: 5
|
|
||||||
})
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
afterEach(function() {
|
|
||||||
if (map) {
|
|
||||||
disposeMap(map);
|
|
||||||
}
|
|
||||||
map = null;
|
|
||||||
});
|
|
||||||
|
|
||||||
function waitForTiles(renderer, sources, layerOptions, onTileLoaded) {
|
|
||||||
const LayerConstructor = TileLayer;
|
|
||||||
let tilesLoading = 0;
|
|
||||||
let tileLoaded = 0;
|
|
||||||
|
|
||||||
const update = function() {
|
|
||||||
if (tilesLoading === tileLoaded) {
|
|
||||||
onTileLoaded();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
sources.forEach(function(source, i) {
|
|
||||||
source.on('tileloadstart', function(event) {
|
|
||||||
tilesLoading++;
|
|
||||||
});
|
|
||||||
source.on('tileloadend', function(event) {
|
|
||||||
tileLoaded++;
|
|
||||||
update();
|
|
||||||
});
|
|
||||||
source.on('tileloaderror', function(event) {
|
|
||||||
expect().fail('Tile failed to load');
|
|
||||||
});
|
|
||||||
|
|
||||||
const options = {
|
|
||||||
source: source
|
|
||||||
};
|
|
||||||
assign(options, layerOptions[i] || layerOptions);
|
|
||||||
map.addLayer(new LayerConstructor(options));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('tile layer with render listener', function() {
|
|
||||||
let source, onAddLayer;
|
|
||||||
|
|
||||||
beforeEach(function() {
|
|
||||||
source = new XYZ({
|
|
||||||
url: 'rendering/ol/data/tiles/osm/{z}/{x}/{y}.png',
|
|
||||||
transition: 0
|
|
||||||
});
|
|
||||||
onAddLayer = function(evt) {
|
|
||||||
evt.element.on('render', function(e) {
|
|
||||||
e.vectorContext.setImageStyle(new CircleStyle({
|
|
||||||
radius: 5,
|
|
||||||
fill: new Fill({color: 'yellow'}),
|
|
||||||
stroke: new Stroke({color: 'red', width: 1})
|
|
||||||
}));
|
|
||||||
e.vectorContext.drawPoint(new Point(
|
|
||||||
transform([-123, 38], 'EPSG:4326', 'EPSG:3857')));
|
|
||||||
});
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('works with the canvas renderer', function(done) {
|
|
||||||
createMap('canvas', undefined, [100, 100]);
|
|
||||||
map.getLayers().on('add', onAddLayer);
|
|
||||||
waitForTiles('canvas', [source], {}, function() {
|
|
||||||
expectResemble(map, 'rendering/ol/layer/expected/render-canvas.png',
|
|
||||||
IMAGE_TOLERANCE, done);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -112,6 +112,19 @@ describe('ol.layer.Layer', function() {
|
|||||||
layer.dispose();
|
layer.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('throws on non-numeric opacity', function() {
|
||||||
|
function create() {
|
||||||
|
new Layer({
|
||||||
|
source: new Source({
|
||||||
|
projection: 'EPSG:4326'
|
||||||
|
}),
|
||||||
|
opacity: 'foo'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(create).to.throwException();
|
||||||
|
});
|
||||||
|
|
||||||
it('accepts a custom render function', function() {
|
it('accepts a custom render function', function() {
|
||||||
let called = false;
|
let called = false;
|
||||||
const layer = new Layer({
|
const layer = new Layer({
|
||||||
@@ -511,6 +524,13 @@ describe('ol.layer.Layer', function() {
|
|||||||
expect(layer.getOpacity()).to.be(0.3);
|
expect(layer.getOpacity()).to.be(0.3);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('throws on types other than number', function() {
|
||||||
|
function set() {
|
||||||
|
layer.setOpacity('foo');
|
||||||
|
}
|
||||||
|
expect(set).to.throwException();
|
||||||
|
});
|
||||||
|
|
||||||
it('triggers a change event', function() {
|
it('triggers a change event', function() {
|
||||||
const listener = sinon.spy();
|
const listener = sinon.spy();
|
||||||
layer.on('propertychange', listener);
|
layer.on('propertychange', listener);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
import {Map, View} from '../../../../src/ol/index.js';
|
||||||
import TileLayer from '../../../../src/ol/layer/Tile.js';
|
import TileLayer from '../../../../src/ol/layer/Tile.js';
|
||||||
import OSM from '../../../../src/ol/source/OSM.js';
|
import {OSM, XYZ} from '../../../../src/ol/source.js';
|
||||||
|
|
||||||
|
|
||||||
describe('ol.layer.Tile', function() {
|
describe('ol.layer.Tile', function() {
|
||||||
@@ -32,4 +33,73 @@ describe('ol.layer.Tile', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('frameState.animate after tile transition with layer opacity', function() {
|
||||||
|
let target, map;
|
||||||
|
|
||||||
|
beforeEach(function(done) {
|
||||||
|
target = document.createElement('div');
|
||||||
|
Object.assign(target.style, {
|
||||||
|
position: 'absolute',
|
||||||
|
left: '-1000px',
|
||||||
|
top: '-1000px',
|
||||||
|
width: '256px',
|
||||||
|
height: '256px'
|
||||||
|
});
|
||||||
|
document.body.appendChild(target);
|
||||||
|
|
||||||
|
map = new Map({
|
||||||
|
target: target,
|
||||||
|
view: new View({center: [0, 0], zoom: 1})
|
||||||
|
});
|
||||||
|
|
||||||
|
map.once('rendercomplete', function() {
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(function() {
|
||||||
|
map.dispose();
|
||||||
|
document.body.removeChild(target);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('sets frameState.animate to false when opacity is 1', function(done) {
|
||||||
|
let lastFrameState;
|
||||||
|
const layer = new TileLayer({
|
||||||
|
opacity: 1,
|
||||||
|
source: new XYZ({
|
||||||
|
url: 'spec/ol/data/osm-0-0-0.png'
|
||||||
|
})
|
||||||
|
});
|
||||||
|
layer.on('postrender', function(event) {
|
||||||
|
lastFrameState = event.frameState;
|
||||||
|
});
|
||||||
|
|
||||||
|
map.once('rendercomplete', function() {
|
||||||
|
expect(lastFrameState.animate).to.be(false);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
map.addLayer(layer);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('sets frameState.animate to false when opacity is 0.5', function(done) {
|
||||||
|
let lastFrameState;
|
||||||
|
const layer = new TileLayer({
|
||||||
|
opacity: 0.5,
|
||||||
|
source: new XYZ({
|
||||||
|
url: 'spec/ol/data/osm-0-0-0.png'
|
||||||
|
})
|
||||||
|
});
|
||||||
|
layer.on('postrender', function(event) {
|
||||||
|
lastFrameState = event.frameState;
|
||||||
|
});
|
||||||
|
|
||||||
|
map.once('rendercomplete', function() {
|
||||||
|
expect(lastFrameState.animate).to.be(false);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
map.addLayer(layer);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -203,6 +203,7 @@ describe('ol.Map', function() {
|
|||||||
target: target,
|
target: target,
|
||||||
layers: [
|
layers: [
|
||||||
new TileLayer({
|
new TileLayer({
|
||||||
|
opacity: 0.5,
|
||||||
source: new XYZ({
|
source: new XYZ({
|
||||||
url: 'spec/ol/data/osm-{z}-{x}-{y}.png'
|
url: 'spec/ol/data/osm-{z}-{x}-{y}.png'
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {getCenter} from '../../../../../src/ol/extent.js';
|
|||||||
import MVT from '../../../../../src/ol/format/MVT.js';
|
import MVT from '../../../../../src/ol/format/MVT.js';
|
||||||
import Point from '../../../../../src/ol/geom/Point.js';
|
import Point from '../../../../../src/ol/geom/Point.js';
|
||||||
import VectorTileLayer from '../../../../../src/ol/layer/VectorTile.js';
|
import VectorTileLayer from '../../../../../src/ol/layer/VectorTile.js';
|
||||||
|
import {getKey} from '../../../../../src/ol/tilecoord.js';
|
||||||
import {get as getProjection} from '../../../../../src/ol/proj.js';
|
import {get as getProjection} from '../../../../../src/ol/proj.js';
|
||||||
import {checkedFonts} from '../../../../../src/ol/render/canvas.js';
|
import {checkedFonts} from '../../../../../src/ol/render/canvas.js';
|
||||||
import RenderFeature from '../../../../../src/ol/render/Feature.js';
|
import RenderFeature from '../../../../../src/ol/render/Feature.js';
|
||||||
@@ -300,12 +301,8 @@ describe('ol.renderer.canvas.VectorTileLayer', function() {
|
|||||||
tileClass: TileClass,
|
tileClass: TileClass,
|
||||||
tileGrid: createXYZ()
|
tileGrid: createXYZ()
|
||||||
});
|
});
|
||||||
source.sourceTiles_ = {
|
source.sourceTileByCoordKey_[getKey(sourceTile.tileCoord)] = sourceTile;
|
||||||
'0/0/0': sourceTile
|
source.sourceTilesByTileKey_[sourceTile.getKey()] = [sourceTile];
|
||||||
};
|
|
||||||
source.sourceTilesByTileKey_ = {
|
|
||||||
'0/0/0': [sourceTile]
|
|
||||||
};
|
|
||||||
executorGroup = {};
|
executorGroup = {};
|
||||||
source.getTile = function() {
|
source.getTile = function() {
|
||||||
const tile = VectorTileSource.prototype.getTile.apply(source, arguments);
|
const tile = VectorTileSource.prototype.getTile.apply(source, arguments);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {createXYZ} from '../../../../src/ol/tilegrid.js';
|
|||||||
import TileGrid from '../../../../src/ol/tilegrid/TileGrid.js';
|
import TileGrid from '../../../../src/ol/tilegrid/TileGrid.js';
|
||||||
import {listen, unlistenByKey} from '../../../../src/ol/events.js';
|
import {listen, unlistenByKey} from '../../../../src/ol/events.js';
|
||||||
import TileState from '../../../../src/ol/TileState.js';
|
import TileState from '../../../../src/ol/TileState.js';
|
||||||
|
import {getCenter} from '../../../../src/ol/extent.js';
|
||||||
|
|
||||||
describe('ol.source.VectorTile', function() {
|
describe('ol.source.VectorTile', function() {
|
||||||
|
|
||||||
@@ -203,4 +204,52 @@ describe('ol.source.VectorTile', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('does not fill up the tile queue', function(done) {
|
||||||
|
const target = document.createElement('div');
|
||||||
|
target.style.width = '100px';
|
||||||
|
target.style.height = '100px';
|
||||||
|
document.body.appendChild(target);
|
||||||
|
const extent = [1824704.739223726, 6141868.096770482, 1827150.7241288517, 6144314.081675608];
|
||||||
|
let url = 'spec/ol/data/14-8938-5680.vector.pbf?';
|
||||||
|
const source = new VectorTileSource({
|
||||||
|
format: new MVT(),
|
||||||
|
url: url,
|
||||||
|
minZoom: 14,
|
||||||
|
maxZoom: 14
|
||||||
|
});
|
||||||
|
|
||||||
|
const map = new Map({
|
||||||
|
target: target,
|
||||||
|
layers: [
|
||||||
|
new VectorTileLayer({
|
||||||
|
extent: extent,
|
||||||
|
source: source
|
||||||
|
})
|
||||||
|
],
|
||||||
|
view: new View({
|
||||||
|
center: getCenter(extent),
|
||||||
|
zoom: 14
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
const limit = 3;
|
||||||
|
let count = 0;
|
||||||
|
source.on('tileloadend', function() {
|
||||||
|
setTimeout(function() {
|
||||||
|
++count;
|
||||||
|
if (count === limit) {
|
||||||
|
document.body.removeChild(target);
|
||||||
|
map.dispose();
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
|
||||||
|
url = url + count;
|
||||||
|
source.setUrl(url);
|
||||||
|
const queue = map.tileQueue_;
|
||||||
|
expect(queue.getTilesLoading()).to.be(0);
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import {listen, listenOnce, unlistenByKey} from '../../../src/ol/events.js';
|
|||||||
import GeoJSON from '../../../src/ol/format/GeoJSON.js';
|
import GeoJSON from '../../../src/ol/format/GeoJSON.js';
|
||||||
import {createXYZ} from '../../../src/ol/tilegrid.js';
|
import {createXYZ} from '../../../src/ol/tilegrid.js';
|
||||||
import TileGrid from '../../../src/ol/tilegrid/TileGrid.js';
|
import TileGrid from '../../../src/ol/tilegrid/TileGrid.js';
|
||||||
import {getKey} from '../../../src/ol/tilecoord.js';
|
|
||||||
import EventType from '../../../src/ol/events/EventType.js';
|
import EventType from '../../../src/ol/events/EventType.js';
|
||||||
|
|
||||||
|
|
||||||
@@ -107,7 +106,7 @@ describe('ol.VectorRenderTile', function() {
|
|||||||
tile.load();
|
tile.load();
|
||||||
expect(tile.getState()).to.be(TileState.LOADING);
|
expect(tile.getState()).to.be(TileState.LOADING);
|
||||||
tile.dispose();
|
tile.dispose();
|
||||||
expect(source.sourceTilesByTileKey_[getKey(tile)]).to.be(undefined);
|
expect(source.sourceTilesByTileKey_[tile.getKey()]).to.be(undefined);
|
||||||
expect(tile.getState()).to.be(TileState.ABORT);
|
expect(tile.getState()).to.be(TileState.ABORT);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||