@@ -900,7 +900,7 @@ export class WebMap extends Observable {
900
900
url : layerInfo . url ,
901
901
wrapX : false ,
902
902
serverType : serverType ,
903
- crossOrigin : 'anonymous' ,
903
+ // crossOrigin: 'anonymous', //在IE11.0.9600版本,会影响通过注册服务打开的iserver地图,不出图。因为没有携带cookie会报跨域问题
904
904
// extent: this.baseLayerExtent,
905
905
prjCoordSys :{ epsgCode : isBaseLayer ? layerInfo . projection . split ( ':' ) [ 1 ] : this . baseProjection . split ( ':' ) [ 1 ] } ,
906
906
format : layerInfo . format
@@ -1763,9 +1763,12 @@ export class WebMap extends Observable {
1763
1763
let that = this , dataSource = layer . dataSource ,
1764
1764
url = layer . dataSource . url ,
1765
1765
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
+ }
1767
1770
//因为itest上使用的https,iserver是http,所以要加上代理
1768
- Util . getFeatureBySQL ( requestUrl , [ dataSourceName ] , function ( result ) {
1771
+ Util . getFeatureBySQL ( requestUrl , [ dataSourceName ] , serviceOptions , function ( result ) {
1769
1772
let features = that . parseGeoJsonData2Feature ( {
1770
1773
allDatas : {
1771
1774
features : result . result . features . features
@@ -2241,9 +2244,12 @@ export class WebMap extends Observable {
2241
2244
if ( dataSource . type === "USER_DATA" || dataSource . accessType === "DIRECT" ) {
2242
2245
that . addGeojsonFromUrl ( layerInfo , null , layerIndex )
2243
2246
} 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
+ }
2245
2251
//因为itest上使用的https,iserver是http,所以要加上代理
2246
- Util . getFeatureBySQL ( requestUrl , [ dataSourceName ] , function ( result ) {
2252
+ Util . getFeatureBySQL ( requestUrl , [ dataSourceName ] , serviceOptions , function ( result ) {
2247
2253
let features = that . parseGeoJsonData2Feature ( {
2248
2254
allDatas : {
2249
2255
features : result . result . features . features
@@ -3516,18 +3522,27 @@ export class WebMap extends Observable {
3516
3522
* @returns {Promise<T | never> } 请求地址
3517
3523
*/
3518
3524
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 ) ;
3524
3526
//如果传入进来的url带了代理则不需要处理
3525
3527
if ( this . excludePortalProxyUrl ) {
3526
3528
return ;
3527
3529
}
3528
3530
return CommonUtil . isInTheSameDomain ( url ) ? url : `${ this . getProxy ( ) } ${ encodeURIComponent ( url ) } ` ;
3529
3531
}
3530
3532
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
+
3531
3546
/**
3532
3547
* @private
3533
3548
* @function ol.supermap.WebMap.prototype.getProxy
0 commit comments