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
10 changes: 9 additions & 1 deletion packages/maptalks/src/geometry/editor/GeometryEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1249,6 +1249,7 @@ class GeometryEditor extends Eventable(Class) {
}

let pauseRefresh = false;
let isSplitSegment = false;
function createNewVertexHandle(index: number, ringIndex: number = 0, ringCoordinates: Array<Coordinate>): any {
let vertexCoordinates = ringCoordinates || getVertexCoordinates(ringIndex);
let nextVertex;
Expand All @@ -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',
Expand Down Expand Up @@ -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 {
Expand Down
22 changes: 13 additions & 9 deletions packages/vt/src/layer/layer/VectorTileLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ const defaultOptions: VectorTileLayerOptionsType = {
tileStackDepth: 2,

altitudePropertyName: null,
disableAltitudeWarning: false
disableAltitudeWarning: false,
loadTileErrorLog: true,
loadTileErrorLogIgnoreCodes: [404, 204]
};

/**
Expand Down Expand Up @@ -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() { }
Expand Down Expand Up @@ -1832,7 +1834,7 @@ class VectorTileLayer extends maptalks.TileLayer {
clear() {
const renderer = this.getRenderer();
if (renderer) {
renderer.clearData();
renderer.clearData();
}
return super.clear();
}
Expand Down Expand Up @@ -2011,7 +2013,9 @@ export type VectorTileLayerOptionsType = {
style?: any,

altitudePropertyName?: string,
disableAltitudeWarning?: boolean
disableAltitudeWarning?: boolean,
loadTileErrorLog?: boolean,
loadTileErrorLogIgnoreCodes?: Array<number>;
} & TileLayerOptionsType;

export type AsyncFeatureQueryOptions = {
Expand Down
4 changes: 4 additions & 0 deletions packages/vt/src/layer/renderer/VectorTileLayerRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -549,6 +551,8 @@ class VectorTileLayerRenderer extends CanvasCompatible(TileLayerRendererable(Lay
},
glScale,
disableAltitudeWarning,
loadTileErrorLog,
loadTileErrorLogIgnoreCodes,
altitudePropertyName,
zScale: this._zScale,
centimeterToPoint,
Expand Down
15 changes: 12 additions & 3 deletions packages/vt/src/worker/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isNumber } from '../common/Util';
import Dispatcher from './Dispatcher';

export const initialize = function () {
Expand All @@ -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);
});
}
Expand Down
1 change: 1 addition & 0 deletions packages/vt/src/worker/layer/VectorTileLayerWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 13 additions & 5 deletions packages/vt/src/worker/util/Ajax.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);
}
});
Expand Down Expand Up @@ -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);
Expand Down