Skip to content

Commit d1e7a76

Browse files
committed
【ut】fix ut
1 parent 541a789 commit d1e7a76

File tree

20 files changed

+8637
-3539
lines changed

20 files changed

+8637
-3539
lines changed

src/common/mapping/MapStyle.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export function createMapStyleExtending(SuperClass, { MapManager, mapRepo }) {
7373
layer.source && !this.map.getSource(layer.source) && this.map.addSource(layer.source, sources[layer.source]);
7474
this.map.addLayer(layer);
7575
});
76+
Object.assign(this.mapOptions.style, { layers, sources });
7677
this._layerIdRenameMapList = layerIdMapList;
7778
this._sendMapToUser();
7879
}
@@ -110,18 +111,22 @@ export function createMapStyleExtending(SuperClass, { MapManager, mapRepo }) {
110111
}
111112

112113
_generateAppreciableLayers() {
113-
const layers = this.mapOptions.style.layers.map((layer) => {
114-
const matchLayer = this._layerIdRenameMapList.find((item) => item.originId === layer.id) || {
115-
renderId: layer.id
116-
};
117-
const overlayLayers = {
118-
id: matchLayer.renderId,
119-
name: layer.id,
120-
renderLayers: [matchLayer.renderId]
121-
};
122-
return overlayLayers;
123-
});
124-
return layers;
114+
return this.mapOptions.style.layers.reduce((layers, layer) => {
115+
const id = layer['source-layer'] || layer.source || layer.id;
116+
const matchLayer = layers.find(item => item.id === id);
117+
if (matchLayer) {
118+
matchLayer.renderLayers.push(layer.id);
119+
} else {
120+
const matchRenameLayer = this._layerIdRenameMapList.find((item) => item.renderId === layer.id);
121+
layers.push({
122+
...layer,
123+
id,
124+
name: matchRenameLayer && matchRenameLayer.originId,
125+
renderLayers: [layer.id]
126+
});
127+
}
128+
return layers;
129+
}, []);
125130
}
126131

127132
_sendMapToUser() {

src/common/mapping/WebMap.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
mapOptions = { style: { version: 8, sources: {}, layers: [] } }
5757
) {
5858
super();
59-
this.mapId = id;
6059
if (typeof id === 'string' || typeof id === 'number') {
6160
this.mapId = id;
6261
} else if (id !== null && typeof id === 'object') {

src/common/mapping/WebMapV2.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,16 +425,16 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) {
425425
}
426426

427427
if (type === 'tile') {
428-
this._initBaseLayer(layer, () => {
429-
this._addLayerSucceeded();
430-
});
431428
if (layer.autoUpdateTime) {
432429
this._layerTimerList.push(
433430
setInterval(() => {
434431
this._initBaseLayer(layer);
435432
}, layer.autoUpdateTime)
436433
);
437434
}
435+
this._initBaseLayer(layer, () => {
436+
this._addLayerSucceeded();
437+
});
438438
} else {
439439
this.getLayerFeatures(layer, _taskID, type);
440440
if (layer.autoUpdateTime) {

src/common/mapping/WebMapV3.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export const LEGEND_STYLE_TYPES = {
158158
IMAGE: 'image',
159159
STYLE: 'style'
160160
};
161-
export function createWebMapV3Extending(SuperClass, { MapManager, mapRepo, l7LayerUtil }) {
161+
export function createWebMapV3Extending(SuperClass, { MapManager, mapRepo, mapRepoName, l7LayerUtil }) {
162162
return class WebMap extends SuperClass {
163163
constructor(mapId, options, mapOptions = {}) {
164164
super();
@@ -322,7 +322,7 @@ export function createWebMapV3Extending(SuperClass, { MapManager, mapRepo, l7Lay
322322
if (typeof crs === 'object') {
323323
baseProjection = crs.name;
324324
if (!mapRepo.CRS) {
325-
const error = `The EPSG code ${baseProjection} needs to include mapbox-gl-enhance.js. Refer to the example: https://iclient.supermap.io/examples/mapboxgl/editor.html#mvtVectorTile_2362`;
325+
const error = `The EPSG code ${baseProjection} needs to include ${mapRepoName}-enhance.js. Refer to the example: https://iclient.supermap.io/examples/${mapRepoName.replace('-', '')}/editor.html#mvtVectorTile_2362`;
326326
this.fire('getmapinfofailed', { error: error });
327327
console.error(error);
328328
return;

src/common/mapping/utils/AppreciableLayerBase.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export class AppreciableLayerBase {
55
this.map = options.map;
66
this.layers = options.layers || [];
77
this.appendLayers = options.appendLayers || false;
8-
this.unexpectedSourceNames = ['tdt-search-', 'tdt-route-', 'smmeasure', 'mapbox-gl-draw', /tracklayer-\d+-line/];
8+
this.unexpectedSourceNames = ['tdt-search-', 'tdt-route-', 'smmeasure', 'mapbox-gl-draw', 'maplibre-gl-draw', /tracklayer-\d+-line/];
99
}
1010

1111
setSelfLayers(layers) {
@@ -39,6 +39,7 @@ export class AppreciableLayerBase {
3939
return layer.metadata.parentLayerId;
4040
}
4141
// 针对 MapboxStyle 或者其它额外的 layer
42+
// type: background 和某些 overlaymanager layers 只有 id
4243
return layer.sourceLayer || layer.source || layer.id;
4344
}
4445

src/common/mapping/utils/SourceListModelV2.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,15 @@ export class SourceListModel extends AppreciableLayerBase {
3434
this.layers.forEach((item) => {
3535
const matchLayers = nextLayers.filter((layer) => this._isBelongToMapJSON(item, layer));
3636
const matchLayer = matchLayers.find(renderLayer => renderLayer.id === item.id);
37-
if (matchLayer) {
38-
selfLayers.push({
39-
...matchLayer,
40-
layerInfo: { ...item, dataSource: item.dataSource || (item.serverId && { serverId: item.serverId }) }
41-
});
37+
if (matchLayers.length > 0) {
38+
if (matchLayer) {
39+
selfLayers.push({
40+
...matchLayer,
41+
layerInfo: { ...item, dataSource: item.dataSource || (item.serverId && { serverId: item.serverId }) }
42+
});
43+
} else {
44+
selfLayers.push(...matchLayers);
45+
}
4246
selfLayerIds.push(...item.renderLayers);
4347
}
4448
});

src/mapboxgl/mapping/WebMap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import MapManager from './webmap/MapManager';
1414
const l7LayerUtil = L7LayerUtil({ featureFilter, expression, spec, L7Layer, L7 });
1515
export class WebMap extends createWebMapExtending(mapboxgl.Evented, { mapRepo: mapboxgl }) {
1616
_createWebMapFactory(type) {
17-
const commonFactoryOptions = { MapManager, mapRepo: mapboxgl };
17+
const commonFactoryOptions = { MapManager, mapRepo: mapboxgl, mapRepoName: 'mapbox-gl' };
1818
switch (type) {
1919
case 'MapStyle':
2020
return createMapStyleExtending(createMapClassExtending(mapboxgl.Evented), commonFactoryOptions);

src/maplibregl/mapping/WebMap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const l7LayerUtil = L7LayerUtil({ featureFilter, expression, spec, L7Layer, L7})
1515

1616
export class WebMap extends createWebMapExtending(maplibregl.Evented, { LngLat: maplibregl.LngLat, CRS: maplibregl.CRS }) {
1717
_createWebMapFactory(type) {
18-
const commonFactoryOptions = { MapManager, mapRepo: maplibregl };
18+
const commonFactoryOptions = { MapManager, mapRepo: maplibregl, mapRepoName: 'maplibre-gl' };
1919
switch (type) {
2020
case 'MapStyle':
2121
return createMapStyleExtending(createMapClassExtending(maplibregl.Evented), commonFactoryOptions);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy