Skip to content

Commit 445a840

Browse files
[FIX]ut 和mapid json
1 parent 8a96fc3 commit 445a840

File tree

3 files changed

+1913
-535
lines changed

3 files changed

+1913
-535
lines changed

src/common/mapping/WebMapV3.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,8 @@ export function createWebMapV3Extending(SuperClass, { MapManager, mapRepo, crsMa
375375
};
376376
if (this._relatedInfo.projectInfo) {
377377
this._mapResourceInfo = JSON.parse(this._relatedInfo.projectInfo);
378+
const catalogFilters = this._getFiltersByCatalog();
379+
this._changeMapInfoFilter(catalogFilters);
378380
}
379381
this._createMapRelatedInfo();
380382
this._addLayersToMap();

test/mapboxgl/mapping/WebMapV3Spec.js

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -169,34 +169,67 @@ describe('mapboxgl-webmap3.0', () => {
169169
if (url.indexOf('map.json') > -1) {
170170
return Promise.resolve(new Response(mapstudioWebMap_filters));
171171
}
172-
if (url.indexOf('617580084.json') > -1) {
172+
if (url.indexOf('932266699.json') > -1) {
173173
return Promise.resolve(new Response(msProjectINfo_filters));
174174
}
175-
if (url.indexOf('/sprite') > -1) {
176-
return Promise.resolve(new Response(msSpriteInfo));
175+
if (url.indexOf('/sprites') > -1) {
176+
return Promise.resolve(new Response(spriteJson));
177177
}
178178
return Promise.resolve();
179179
});
180-
mapstudioWebmap = new WebMap(id, {
180+
mapstudioWebmap = new WebMap('932266699', {
181181
server: server
182182
});
183183

184184
mapstudioWebmap.on('mapcreatesucceeded', ({ map }) => {
185185
expect(map).not.toBeUndefined();
186186
expect(mapstudioWebmap.map).toEqual(map);
187-
const style = map.getStyle();
188187
const webMapV3 = mapstudioWebmap._getWebMapInstance();
189-
const mapInfo = JSON.parse(mapstudioWebMap_symbol);
190-
expect(style.layers.length).toBe(mapInfo.layers.length);
191-
expect(webMapV3._mapInfo.layers[0].filter).toBe([]);
192-
expect(webMapV3._mapInfo.layers[1].filter).toBe([]);
193-
expect(webMapV3._mapInfo.layers[2].filter).toBe([]);
194-
expect(webMapV3._mapInfo.layers[3].filter).toBe([]);
195-
expect(webMapV3._mapInfo.layers[4].filter).toBe([]);
188+
expect(webMapV3._mapInfo.layers[1].filter).toEqual([
189+
'all',
190+
['all', ['==', ['get', 'Ctype'], ''], ['!=', ['get', 'smpid'], '']],
191+
['all', ['all', ['all', ['all', ['!=', ['get', 'smpid'], 121]]]]]
192+
]);
193+
expect(webMapV3._mapInfo.layers[2].filter).toEqual([
194+
'all',
195+
['all', ['==', ['get', 'Ctype'], ''], ['!=', ['get', 'smpid'], '']],
196+
['all', ['all', ['all', ['any', ['==', ['get', 'smpid'], 121]]]]]
197+
]);
196198
done();
197199
});
198200
});
201+
it('filters mapId is JSON', (done) => {
202+
spyOn(FetchRequest, 'get').and.callFake((url) => {
203+
if (url.indexOf('/sprites') > -1) {
204+
return Promise.resolve(new Response(msSpriteInfo));
205+
}
206+
return Promise.resolve();
207+
});
208+
const mapInfo = JSON.parse(mapstudioWebMap_filters);
209+
mapstudioWebmap = new WebMapV3(mapInfo, {
210+
server: server,
211+
target: 'map',
212+
iportalServiceProxyUrlPrefix: 'mapId is JSON',
213+
relatedInfo: JSON.parse(msProjectINfo_filters)
214+
});
215+
mapstudioWebmap.initializeMap(mapInfo);
199216

217+
mapstudioWebmap.on('mapcreatesucceeded', ({ map }) => {
218+
expect(map).not.toBeUndefined();
219+
expect(mapstudioWebmap.map).toEqual(map);
220+
expect(mapstudioWebmap._mapInfo.layers[1].filter).toEqual([
221+
'all',
222+
['all', ['==', ['get', 'Ctype'], ''], ['!=', ['get', 'smpid'], '']],
223+
['all', ['all', ['all', ['all', ['!=', ['get', 'smpid'], 121]]]]]
224+
]);
225+
expect(mapstudioWebmap._mapInfo.layers[2].filter).toEqual([
226+
'all',
227+
['all', ['==', ['get', 'Ctype'], ''], ['!=', ['get', 'smpid'], '']],
228+
['all', ['all', ['all', ['any', ['==', ['get', 'smpid'], 121]]]]]
229+
]);
230+
done();
231+
});
232+
});
200233
it('mapId is JSON', (done) => {
201234
spyOn(FetchRequest, 'get').and.callFake((url) => {
202235
if (url.indexOf('/sprite') > -1) {

0 commit comments

Comments
 (0)