From d8a0f06262cde6df57cbc45add9c4201619464a6 Mon Sep 17 00:00:00 2001 From: hu de yi Date: Thu, 18 Sep 2025 14:51:21 +0800 Subject: [PATCH 1/2] VectorTileLayer add loadTileErrorLog for log loadTile error (#2641) * VectorTileLayer add loadTileErrorLog for log loadTile error * fix typing --- .../vt/src/layer/layer/VectorTileLayer.ts | 22 +++++++++++-------- .../layer/renderer/VectorTileLayerRenderer.js | 4 ++++ packages/vt/src/worker/index.js | 15 ++++++++++--- .../src/worker/layer/VectorTileLayerWorker.js | 1 + packages/vt/src/worker/util/Ajax.js | 18 ++++++++++----- 5 files changed, 43 insertions(+), 17 deletions(-) diff --git a/packages/vt/src/layer/layer/VectorTileLayer.ts b/packages/vt/src/layer/layer/VectorTileLayer.ts index 38a0f1b062..7b3d6143f1 100644 --- a/packages/vt/src/layer/layer/VectorTileLayer.ts +++ b/packages/vt/src/layer/layer/VectorTileLayer.ts @@ -88,7 +88,9 @@ const defaultOptions: VectorTileLayerOptionsType = { tileStackDepth: 2, altitudePropertyName: null, - disableAltitudeWarning: false + disableAltitudeWarning: false, + loadTileErrorLog: true, + loadTileErrorLogIgnoreCodes: [404, 204] }; /** @@ -347,12 +349,12 @@ class VectorTileLayer extends maptalks.TileLayer { } forceReload(): this { - // expire cached tiles in worker - const renderer = this.getRenderer() as any; - if (renderer) { - renderer._incrWorkerCacheIndex(); - } - return super.forceReload(); + // expire cached tiles in worker + const renderer = this.getRenderer() as any; + if (renderer) { + renderer._incrWorkerCacheIndex(); + } + return super.forceReload(); } onWorkerReady() { } @@ -1832,7 +1834,7 @@ class VectorTileLayer extends maptalks.TileLayer { clear() { const renderer = this.getRenderer(); if (renderer) { - renderer.clearData(); + renderer.clearData(); } return super.clear(); } @@ -2011,7 +2013,9 @@ export type VectorTileLayerOptionsType = { style?: any, altitudePropertyName?: string, - disableAltitudeWarning?: boolean + disableAltitudeWarning?: boolean, + loadTileErrorLog?: boolean, + loadTileErrorLogIgnoreCodes?: Array; } & TileLayerOptionsType; export type AsyncFeatureQueryOptions = { diff --git a/packages/vt/src/layer/renderer/VectorTileLayerRenderer.js b/packages/vt/src/layer/renderer/VectorTileLayerRenderer.js index 026076ed3d..948757e1f7 100644 --- a/packages/vt/src/layer/renderer/VectorTileLayerRenderer.js +++ b/packages/vt/src/layer/renderer/VectorTileLayerRenderer.js @@ -537,6 +537,8 @@ class VectorTileLayerRenderer extends CanvasCompatible(TileLayerRendererable(Lay const referrer = window && window.location.href; const altitudePropertyName = this.layer.options['altitudePropertyName']; const disableAltitudeWarning = this.layer.options['disableAltitudeWarning']; + const loadTileErrorLog = this.layer.options.loadTileErrorLog; + const loadTileErrorLogIgnoreCodes = this.layer.options.loadTileErrorLogIgnoreCodes; const loadTileOpitons = { tileInfo: { res: tileInfo.res, @@ -549,6 +551,8 @@ class VectorTileLayerRenderer extends CanvasCompatible(TileLayerRendererable(Lay }, glScale, disableAltitudeWarning, + loadTileErrorLog, + loadTileErrorLogIgnoreCodes, altitudePropertyName, zScale: this._zScale, centimeterToPoint, diff --git a/packages/vt/src/worker/index.js b/packages/vt/src/worker/index.js index 5ef654ad29..bebf74ec97 100644 --- a/packages/vt/src/worker/index.js +++ b/packages/vt/src/worker/index.js @@ -1,3 +1,4 @@ +import { isNumber } from '../common/Util'; import Dispatcher from './Dispatcher'; export const initialize = function () { @@ -15,11 +16,19 @@ export const onmessage = function (message, postResponse) { } } else { const command = data.command; + const loadTileErrorLog = (data.params || {}).loadTileErrorLog; + const loadTileErrorLogIgnoreCodes = (data.params || {}).loadTileErrorLogIgnoreCodes || []; this.dispatcher[command]({ actorId: message.actorId, mapId: data.mapId, layerId: data.layerId, params: data.params }, (err, data, buffers) => { - if (err && err.status !== 404 && err.status !== 204 && !err.loading) { - // err.loading 为true时,说明geojson-vt正在创建索引 - console.error(command, err); + if (loadTileErrorLog && err && !err.loading) { + const status = err.status; + if (isNumber(status) && loadTileErrorLogIgnoreCodes.indexOf(status) === -1) { + console.error(command, err); + } } + // if (err && err.status !== 404 && err.status !== 204 && !err.loading) { + // // err.loading 为true时,说明geojson-vt正在创建索引 + // console.error(command, err); + // } postResponse(err, data, buffers); }); } diff --git a/packages/vt/src/worker/layer/VectorTileLayerWorker.js b/packages/vt/src/worker/layer/VectorTileLayerWorker.js index e88c8d220d..459861896d 100644 --- a/packages/vt/src/worker/layer/VectorTileLayerWorker.js +++ b/packages/vt/src/worker/layer/VectorTileLayerWorker.js @@ -48,6 +48,7 @@ export default class VectorTileLayerWorker extends LayerWorker { }, 1); } fetchOptions.referrer = context.referrer; + fetchOptions.errorLog = context.loadTileErrorLog; return Ajax.getArrayBuffer(url, fetchOptions, (err, response) => { if (!this._cache) { // removed diff --git a/packages/vt/src/worker/util/Ajax.js b/packages/vt/src/worker/util/Ajax.js index 70811de528..e49224fc04 100644 --- a/packages/vt/src/worker/util/Ajax.js +++ b/packages/vt/src/worker/util/Ajax.js @@ -1,6 +1,6 @@ -import { isFunction, uid } from '../../common/Util'; +import { isFunction, isNil, uid } from '../../common/Util'; -const USE_FETCH = typeof fetch === 'function' && typeof AbortController === 'function'; +const USE_FETCH = typeof fetch === 'function' && typeof AbortController === 'function'; /** * @classdesc @@ -68,6 +68,10 @@ const Ajax = { options = t; } options = options || {}; + let errorLog = options.errorLog; + if (isNil(errorLog)) { + errorLog = true; + } if (options.method) { options.method = options.method.toUpperCase(); } @@ -115,14 +119,18 @@ const Ajax = { } }).catch(err => { if (!err.code || err.code !== DOMException.ABORT_ERR) { - console.error('Fetch error:', url, err); + if (errorLog) { + console.error('Fetch error:', url, err); + } cb(err); } }); } }).catch(err => { if (!err.code || err.code !== DOMException.ABORT_ERR) { - console.error('Fetch error:', url, err); + if (errorLog) { + console.error('Fetch error:', url, err); + } cb(err); } }); @@ -185,7 +193,7 @@ const Ajax = { client = new XMLHttpRequest(); } catch (e) { try { client = new ActiveXObject('Msxml2.XMLHTTP'); } catch (e) { - try { client = new ActiveXObject('Microsoft.XMLHTTP'); } catch (e) {} + try { client = new ActiveXObject('Microsoft.XMLHTTP'); } catch (e) { } } } client.onreadystatechange = Ajax._wrapCallback(client, cb); From 106a2bfbbcae8eb42a1cf8c75aff3600ab42fc26 Mon Sep 17 00:00:00 2001 From: hu de yi Date: Thu, 18 Sep 2025 15:35:59 +0800 Subject: [PATCH 2/2] fix Path Edit the new vertex position error when dragstart --- .../maptalks/src/geometry/editor/GeometryEditor.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/maptalks/src/geometry/editor/GeometryEditor.ts b/packages/maptalks/src/geometry/editor/GeometryEditor.ts index cb318b9d78..80b9bd9f19 100644 --- a/packages/maptalks/src/geometry/editor/GeometryEditor.ts +++ b/packages/maptalks/src/geometry/editor/GeometryEditor.ts @@ -1249,6 +1249,7 @@ class GeometryEditor extends Eventable(Class) { } let pauseRefresh = false; + let isSplitSegment = false; function createNewVertexHandle(index: number, ringIndex: number = 0, ringCoordinates: Array): any { let vertexCoordinates = ringCoordinates || getVertexCoordinates(ringIndex); let nextVertex; @@ -1257,7 +1258,12 @@ class GeometryEditor extends Eventable(Class) { } else { nextVertex = vertexCoordinates[index + 1]; } - const vertex = vertexCoordinates[index].add(nextVertex).multi(1 / 2); + + let vertex = vertexCoordinates[index].add(nextVertex).multi(1 / 2); + //add two "new vertex" handles + if (isSplitSegment) { + vertex = coordinatesToContainerPoint(map, vertex); + } const handle = me.createHandle(vertex, { 'symbol': me.options['newVertexHandleSymbol'], 'cursor': 'pointer', @@ -1292,7 +1298,9 @@ class GeometryEditor extends Eventable(Class) { handle.opacity = 1; //add two "new vertex" handles + isSplitSegment = true; newVertexHandles[ringIndex].splice(vertexIndex, 0, createNewVertexHandle.call(me, vertexIndex, ringIndex), createNewVertexHandle.call(me, vertexIndex + 1, ringIndex)); + isSplitSegment = false; pauseRefresh = true; }, onMove: function (): void {