@@ -900,7 +900,7 @@ export class WebMap extends Observable {
900900 url : layerInfo . url ,
901901 wrapX : false ,
902902 serverType : serverType ,
903- crossOrigin : 'anonymous' ,
903+ // crossOrigin: 'anonymous', //在IE11.0.9600版本,会影响通过注册服务打开的iserver地图,不出图。因为没有携带cookie会报跨域问题
904904 // extent: this.baseLayerExtent,
905905 prjCoordSys :{ epsgCode : isBaseLayer ? layerInfo . projection . split ( ':' ) [ 1 ] : this . baseProjection . split ( ':' ) [ 1 ] } ,
906906 format : layerInfo . format
@@ -1763,9 +1763,12 @@ export class WebMap extends Observable {
17631763 let that = this , dataSource = layer . dataSource ,
17641764 url = layer . dataSource . url ,
17651765 dataSourceName = dataSource . dataSourceName || layer . name ;
1766- let requestUrl = that . getRequestUrl ( url ) ;
1766+ let requestUrl = that . formatUrlWithCredential ( url ) , serviceOptions = { } ;
1767+ if ( ! this . excludePortalProxyUrl && ! CommonUtil . isInTheSameDomain ( requestUrl ) ) {
1768+ serviceOptions . proxy = this . getProxy ( ) ;
1769+ }
17671770 //因为itest上使用的https,iserver是http,所以要加上代理
1768- Util . getFeatureBySQL ( requestUrl , [ dataSourceName ] , function ( result ) {
1771+ Util . getFeatureBySQL ( requestUrl , [ dataSourceName ] , serviceOptions , function ( result ) {
17691772 let features = that . parseGeoJsonData2Feature ( {
17701773 allDatas : {
17711774 features : result . result . features . features
@@ -2241,9 +2244,12 @@ export class WebMap extends Observable {
22412244 if ( dataSource . type === "USER_DATA" || dataSource . accessType === "DIRECT" ) {
22422245 that . addGeojsonFromUrl ( layerInfo , null , layerIndex )
22432246 } else {
2244- let requestUrl = that . getRequestUrl ( url ) ;
2247+ let requestUrl = that . formatUrlWithCredential ( url ) , serviceOptions = { } ;
2248+ if ( ! this . excludePortalProxyUrl && ! CommonUtil . isInTheSameDomain ( requestUrl ) ) {
2249+ serviceOptions . proxy = this . getProxy ( ) ;
2250+ }
22452251 //因为itest上使用的https,iserver是http,所以要加上代理
2246- Util . getFeatureBySQL ( requestUrl , [ dataSourceName ] , function ( result ) {
2252+ Util . getFeatureBySQL ( requestUrl , [ dataSourceName ] , serviceOptions , function ( result ) {
22472253 let features = that . parseGeoJsonData2Feature ( {
22482254 allDatas : {
22492255 features : result . result . features . features
@@ -3516,18 +3522,27 @@ export class WebMap extends Observable {
35163522 * @returns {Promise<T | never> } 请求地址
35173523 */
35183524 getRequestUrl ( url ) {
3519- if ( this . credentialValue ) {
3520- //有token之类的配置项
3521- url = url . indexOf ( "?" ) === - 1 ? `${ url } ?${ this . credentialKey } =${ this . credentialValue } ` :
3522- `${ url } &${ this . credentialKey } =${ this . credentialValue } ` ;
3523- }
3525+ this . formatUrlWithCredential ( url ) ;
35243526 //如果传入进来的url带了代理则不需要处理
35253527 if ( this . excludePortalProxyUrl ) {
35263528 return ;
35273529 }
35283530 return CommonUtil . isInTheSameDomain ( url ) ? url : `${ this . getProxy ( ) } ${ encodeURIComponent ( url ) } ` ;
35293531 }
35303532
3533+ /**
3534+ * 给url带上凭证密钥
3535+ * @param {* } url 地址
3536+ */
3537+ formatUrlWithCredential ( url ) {
3538+ if ( this . credentialValue ) {
3539+ //有token之类的配置项
3540+ url = url . indexOf ( "?" ) === - 1 ? `${ url } ?${ this . credentialKey } =${ this . credentialValue } ` :
3541+ `${ url } &${ this . credentialKey } =${ this . credentialValue } ` ;
3542+ }
3543+ return url ;
3544+ }
3545+
35313546 /**
35323547 * @private
35333548 * @function ol.supermap.WebMap.prototype.getProxy
0 commit comments