Skip to content

Commit 80081e6

Browse files
[fix]webmap returnFeaturesOnly
1 parent af11251 commit 80081e6

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/common/mapping/WebMapService.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,8 @@ export class WebMapService {
12081208
fromIndex: 0,
12091209
toIndex: -1,
12101210
maxFeatures: -1,
1211-
returnContent: true
1211+
returnContent: true,
1212+
returnFeaturesOnly: true
12121213
});
12131214
if (baseProjection && baseProjection !== 'EPSG:4326') {
12141215
getFeatureBySQLParams.targetEpsgCode = 4326;

test/common/mapping/WebMapServiceSpec.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,8 @@ describe('WebMapServiceSpec.js', () => {
880880
let getFeatureBySQLParams;
881881
spyOn(FetchRequest, 'post').and.callFake((url, options) => {
882882
getFeatureBySQLParams = options;
883-
return Promise.resolve(new Response(JSON.stringify(REST_DATA_SQL_RESULT)));
883+
expect(url.includes('returnFeaturesOnly=true')).toBeTruthy()
884+
return Promise.resolve(new Response(JSON.stringify(REST_DATA_SQL_RESULT.features)));
884885
});
885886
const type = 'rest_data';
886887
const layer = {
@@ -894,13 +895,14 @@ describe('WebMapServiceSpec.js', () => {
894895
const baseProjection = 'EPSG:3857';
895896
const service = new WebMapService(mapId, options);
896897
const spy = spyOn(service, '_getFeatureBySQL').and.callThrough();;
897-
service.getLayerFeatures(type, layer, baseProjection).then(() => {
898+
service.getLayerFeatures(type, layer, baseProjection).then((res) => {
898899
const params = spy.calls.allArgs()[0];
899900
expect(params[0]).toBe(layer.dataSource.url);
900901
expect(params[1]).toEqual(["中国矢量数据:飞机场"]);
901902
expect(params[4]).toEqual(baseProjection);
902903
expect(typeof getFeatureBySQLParams).toBe('string');
903904
expect(getFeatureBySQLParams).toContain(`'targetEpsgCode':4326`);
905+
expect(res.features instanceof Array).toBeTruthy();
904906
done();
905907
});
906908
});

0 commit comments

Comments
 (0)