Skip to content

Commit

Permalink
[fix]webmap returnFeaturesOnly
Browse files Browse the repository at this point in the history
  • Loading branch information
luoxiao-supermap committed Dec 10, 2024
1 parent af11251 commit 80081e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/common/mapping/WebMapService.js
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,8 @@ export class WebMapService {
fromIndex: 0,
toIndex: -1,
maxFeatures: -1,
returnContent: true
returnContent: true,
returnFeaturesOnly: true
});
if (baseProjection && baseProjection !== 'EPSG:4326') {
getFeatureBySQLParams.targetEpsgCode = 4326;
Expand Down
6 changes: 4 additions & 2 deletions test/common/mapping/WebMapServiceSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,8 @@ describe('WebMapServiceSpec.js', () => {
let getFeatureBySQLParams;
spyOn(FetchRequest, 'post').and.callFake((url, options) => {
getFeatureBySQLParams = options;
return Promise.resolve(new Response(JSON.stringify(REST_DATA_SQL_RESULT)));
expect(url.includes('returnFeaturesOnly=true')).toBeTruthy()
return Promise.resolve(new Response(JSON.stringify(REST_DATA_SQL_RESULT.features)));
});
const type = 'rest_data';
const layer = {
Expand All @@ -894,13 +895,14 @@ describe('WebMapServiceSpec.js', () => {
const baseProjection = 'EPSG:3857';
const service = new WebMapService(mapId, options);
const spy = spyOn(service, '_getFeatureBySQL').and.callThrough();;
service.getLayerFeatures(type, layer, baseProjection).then(() => {
service.getLayerFeatures(type, layer, baseProjection).then((res) => {
const params = spy.calls.allArgs()[0];
expect(params[0]).toBe(layer.dataSource.url);
expect(params[1]).toEqual(["中国矢量数据:飞机场"]);
expect(params[4]).toEqual(baseProjection);
expect(typeof getFeatureBySQLParams).toBe('string');
expect(getFeatureBySQLParams).toContain(`'targetEpsgCode':4326`);
expect(res.features instanceof Array).toBeTruthy();
done();
});
});
Expand Down

0 comments on commit 80081e6

Please sign in to comment.