11/* Copyright© 2000 - 2019 SuperMap Software Co.Ltd. All rights reserved.
22 * This program are made available under the terms of the Apache License, Version 2.0
33 * which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
4- import { SuperMap } from ' ../SuperMap' ;
5- import { IPortalServicesQueryParam } from ' ./iPortalServicesQueryParam' ;
6- import { IPortalMapsQueryParam } from ' ./iPortalMapsQueryParam' ;
7- import { FetchRequest } from ' ../util/FetchRequest' ;
8- import { IPortalService } from ' ./iPortalService' ;
9- import { IPortalMap } from ' ./iPortalMap' ;
10- import { IPortalServiceBase } from ' ./iPortalServiceBase' ;
4+ import { SuperMap } from " ../SuperMap" ;
5+ import { IPortalServicesQueryParam } from " ./iPortalServicesQueryParam" ;
6+ import { IPortalMapsQueryParam } from " ./iPortalMapsQueryParam" ;
7+ import { FetchRequest } from " ../util/FetchRequest" ;
8+ import { IPortalService } from " ./iPortalService" ;
9+ import { IPortalMap } from " ./iPortalMap" ;
10+ import { IPortalServiceBase } from " ./iPortalServiceBase" ;
1111
1212/**
1313 * @class SuperMap.iPortal
@@ -17,9 +17,8 @@ import { IPortalServiceBase } from './iPortalServiceBase';
1717 * @param {string } iportalUrl - 地址。
1818 */
1919export class IPortal extends IPortalServiceBase {
20-
2120 constructor ( iportalUrl , options ) {
22- super ( iportalUrl , options ) ;
21+ super ( iportalUrl , options ) ;
2322 this . iportalUrl = iportalUrl ;
2423 options = options || { } ;
2524 this . withCredentials = options . withCredentials || false ;
@@ -31,7 +30,7 @@ export class IPortal extends IPortalServiceBase {
3130 * @returns {Promise } 返回包含 iportal web 资源信息的 Promise 对象。
3231 */
3332 load ( ) {
34- return FetchRequest . get ( this . iportalUrl + ' /web' ) ;
33+ return FetchRequest . get ( this . iportalUrl + " /web" ) ;
3534 }
3635
3736 /**
@@ -45,9 +44,9 @@ export class IPortal extends IPortalServiceBase {
4544 return null ;
4645 }
4746 var serviceUrl = this . iportalUrl + "/web/services" ;
48- return this . request ( "GET" , serviceUrl , queryParams ) . then ( function ( result ) {
47+ return this . request ( "GET" , serviceUrl , queryParams ) . then ( function ( result ) {
4948 var services = [ ] ;
50- result . content . map ( function ( serviceJsonObj ) {
49+ result . content . map ( function ( serviceJsonObj ) {
5150 services . push ( new IPortalService ( serviceUrl , serviceJsonObj ) ) ;
5251 return serviceJsonObj ;
5352 } ) ;
@@ -82,22 +81,23 @@ export class IPortal extends IPortalServiceBase {
8281 } else {
8382 mapsUrl = this . iportalUrl + "/web/maps" ;
8483 }
85- return this . request ( "GET" , mapsUrl , queryParams ) . then ( function ( result ) {
84+ return this . request ( "GET" , mapsUrl , queryParams ) . then ( function ( result ) {
8685 var mapRetult = { } ;
8786 var maps = [ ] ;
88- result . content . map ( function ( mapJsonObj ) {
89- maps . push ( new IPortalMap ( mapsUrl + "/" + mapJsonObj . id , mapJsonObj ) ) ;
90- return mapJsonObj ;
91- } ) ;
92- mapRetult . content = maps ;
93- mapRetult . currentPage = result . currentPage ;
94- mapRetult . pageSize = result . pageSize ;
95- mapRetult . total = result . total ;
96- mapRetult . totalPage = result . totalPage ;
97- return mapRetult ;
87+ if ( result . content && result . content . length > 0 ) {
88+ result . content . map ( function ( mapJsonObj ) {
89+ maps . push ( new IPortalMap ( mapsUrl + "/" + mapJsonObj . id , mapJsonObj ) ) ;
90+ return mapJsonObj ;
91+ } ) ;
92+ mapRetult . content = maps ;
93+ mapRetult . currentPage = result . currentPage ;
94+ mapRetult . pageSize = result . pageSize ;
95+ mapRetult . total = result . total ;
96+ mapRetult . totalPage = result . totalPage ;
97+ return mapRetult ;
98+ }
9899 } ) ;
99100 }
100101}
101102
102103SuperMap . iPortal = IPortal ;
103-
0 commit comments