Skip to content

Commit cc7440c

Browse files
[FIX]ut 和mapid json
1 parent 4fb1f17 commit cc7440c

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
@@ -431,6 +431,8 @@ export function createWebMapV3Extending(SuperClass, { MapManager, mapRepo, crsMa
431431
};
432432
if (this._relatedInfo.projectInfo) {
433433
this._mapResourceInfo = JSON.parse(this._relatedInfo.projectInfo);
434+
const catalogFilters = this._getFiltersByCatalog();
435+
this._changeMapInfoFilter(catalogFilters);
434436
}
435437
this._createMapRelatedInfo();
436438
this._addLayersToMap();

test/mapboxgl/mapping/WebMapV3Spec.js

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

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

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

0 commit comments

Comments
 (0)