Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -610,11 +610,15 @@ const TileLayerRenderable = function <T extends MixinConstructor>(Base: T) {
const tileImage = this.loadTile(tile);
if (tileImage.loadTime === undefined) {
// tile image's loading may not be async
this.tilesLoading[tile['id']] = {
image: tileImage,
current: true,
info: tile
};
// if empty not add to tilesLoading, it is not async
//空的瓦片不加入加载队列,因为不是异步的
if (!(tileImage as any)._empty) {
this.tilesLoading[tile['id']] = {
image: tileImage,
current: true,
info: tile
};
}
}
}
}
Expand Down Expand Up @@ -721,7 +725,11 @@ const TileLayerRenderable = function <T extends MixinConstructor>(Base: T) {
}

removeTileLoading(tileInfo: Tile['info']): void {
delete this.tilesLoading[tileInfo.id];
if (this.tilesLoading[tileInfo.id]) {
delete this.tilesLoading[tileInfo.id];
} else {
// console.warn('Tile not found in tilesLoading:', tileInfo.id);
}
// need to setToRedraw to let tiles blocked by loadingLimit continue to load
this.setToRedraw();
}
Expand Down
12 changes: 12 additions & 0 deletions packages/vt/src/layer/renderer/VectorTileLayerRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,18 @@ class VectorTileLayerRenderer extends CanvasCompatible(TileLayerRendererable(Lay
tiles: [tileInfo]
};
this._requestingMVT[url].keys[tileInfo.id] = 1;

if (this.layer._dataExtent && this.layer._getTileBBox) {
const tileBBOX = this.layer._getTileBBox(tileInfo);
const dataBBOX = this.layer._dataExtent.toBBOX();
const bboxIntersect = maptalks.BBOXUtil.bboxIntersect;
//when data extent and tile extent not Intersect,return empty
if (tileBBOX && dataBBOX && !bboxIntersect(tileBBOX, dataBBOX)) {
this._onReceiveMVTData(url, null, null);
return { _empty: true };
}
}

const fetchOptions = this.layer.options['fetchOptions'];
const referrer = window && window.location.href;
const altitudePropertyName = this.layer.options['altitudePropertyName'];
Expand Down
34 changes: 18 additions & 16 deletions packages/vt/src/worker/layer/GeojsonLayerWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ export default class GeoJSONLayerWorker extends BaseLayerWorker {
data = JSON.parse(data);
}
const features = Array.isArray(data) ? data : data.features;
const length = features && features.length;
// const length = features && features.length;
this._genOMBB(features);
let sample1000 = features;
if (features && length > 1000) {
sample1000 = [];
for (let i = 0; i < length; i++) {
insertSample(features[i], sample1000, i, length);
}
}
// if (features && length > 1000) {
// sample1000 = [];
// for (let i = 0; i < length; i++) {
// insertSample(features[i], sample1000, i, length);
// }
// }
this._generate(sample1000, null, data, options, cb);
}
}
Expand Down Expand Up @@ -177,6 +177,7 @@ export default class GeoJSONLayerWorker extends BaseLayerWorker {
const idMap = new Map();
let uid = 0;
const feaIdProp = this.options.featureIdProperty;
// eslint-disable-next-line no-unused-vars
function visit(f, index, length) {
if (!f) {
return;
Expand Down Expand Up @@ -206,8 +207,9 @@ export default class GeoJSONLayerWorker extends BaseLayerWorker {
// idMap[f.id].coordinates = null;
}
idMap.set(f.id, feature);
sample1000.push(f);

insertSample(f, sample1000, index, length);
// insertSample(f, sample1000, index, length);
}
if (data) {
const length = data.length;
Expand Down Expand Up @@ -288,14 +290,14 @@ export default class GeoJSONLayerWorker extends BaseLayerWorker {
}
}

function insertSample(feature, sample1000, i, length) {
const step = Math.floor(length / (1000 - 2));
if (i === 0 || i === length - 1) {
sample1000.push(feature);
} else if ((step === 0 || i % step === 0) && sample1000.length < 999) {
sample1000.push(feature);
}
}
// function insertSample(feature, sample1000, i, length) {
// const step = Math.floor(length / (1000 - 2));
// if (i === 0 || i === length - 1) {
// sample1000.push(feature);
// } else if ((step === 0 || i % step === 0) && sample1000.length < 999) {
// sample1000.push(feature);
// }
// }

function isEmptyData(data) {
if (!data) {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module.exports = {
center: [0.001, 0.001],
zoom: 17
},
renderingCount: 1,
renderingCount: 2,
sceneConfig: {
ground: {
enable: true,
Expand Down