1+ import Browser from '../../core/Browser' ;
12import { extend } from '../../core/util' ;
23import TileLayer from './TileLayer' ;
34
@@ -18,7 +19,7 @@ import TileLayer from './TileLayer';
1819const options = {
1920 crs : null ,
2021 uppercase : false ,
21- detectRetina : false
22+ detectRetina : false
2223} ;
2324
2425const defaultWmsParams = {
@@ -30,6 +31,7 @@ const defaultWmsParams = {
3031 transparent : false ,
3132 version : '1.1.1'
3233} ;
34+ let wmsExcludeParams ;
3335
3436/**
3537 * @classdesc
@@ -55,19 +57,33 @@ class WMSTileLayer extends TileLayer {
5557
5658 constructor ( id , options ) {
5759 super ( id ) ;
58- const wmsParams = extend ( { } , defaultWmsParams ) ;
59- for ( const p in options ) {
60- if ( ! ( p in this . options ) ) {
61- wmsParams [ p ] = options [ p ] ;
62- }
60+ if ( ! wmsExcludeParams ) {
61+ wmsExcludeParams = extend ( { } , this . options ) ;
6362 }
63+ this . wmsParams = extend ( { } , defaultWmsParams ) ;
6464 this . setOptions ( options ) ;
6565 this . setZIndex ( options . zIndex ) ;
66+ if ( ! Browser . proxy ) {
67+ this . _optionsHook ( options ) ;
68+ }
69+ }
70+
71+ //in Hook,Reset wmsParams
72+ _optionsHook ( options = { } ) {
73+ for ( const p in options ) {
74+ //clear tilesize cache
75+ if ( p === 'tileSize' ) {
76+ this . _tileSize = null ;
77+ }
78+ if ( ! ( p in wmsExcludeParams ) ) {
79+ this . wmsParams [ p ] = options [ p ] ;
80+ }
81+ }
6682 const tileSize = this . getTileSize ( ) ;
67- wmsParams . width = tileSize . width ;
68- wmsParams . height = tileSize . height ;
69- this . wmsParams = wmsParams ;
70- this . _wmsVersion = parseFloat ( wmsParams . version ) ;
83+ this . wmsParams . width = tileSize . width ;
84+ this . wmsParams . height = tileSize . height ;
85+ this . _wmsVersion = parseFloat ( this . wmsParams . version ) ;
86+ return this ;
7187 }
7288
7389 onAdd ( ) {
@@ -88,7 +104,7 @@ class WMSTileLayer extends TileLayer {
88104 const max = tileExtent . getMax ( ) ,
89105 min = tileExtent . getMin ( ) ;
90106
91- const bbox = ( this . _wmsVersion >= 1.3 && ( this . wmsParams . crs === 'EPSG:4326' || this . wmsParams . crs === 'EPSG:4490' ) ?
107+ const bbox = ( this . _wmsVersion >= 1.3 && ( this . wmsParams . crs === 'EPSG:4326' || this . wmsParams . crs === 'EPSG:4490' ) ?
92108 [ min . y , min . x , max . y , max . x ] :
93109 [ min . x , min . y , max . x , max . y ] ) . join ( ',' ) ;
94110
0 commit comments