@@ -48,7 +48,7 @@ export class MapLayer extends HTMLElement {
4848 }
4949
5050 get opacity ( ) {
51- return this . _layer . _container . style . opacity || this . _layer . options . opacity ;
51+ return this . _opacity ;
5252 }
5353
5454 set opacity ( val ) {
@@ -126,9 +126,6 @@ export class MapLayer extends HTMLElement {
126126 { once : true }
127127 ) ;
128128 let base = this . baseURI ? this . baseURI : document . baseURI ;
129- let opacity_value = this . hasAttribute ( 'opacity' )
130- ? this . getAttribute ( 'opacity' )
131- : '1.0' ;
132129
133130 const headers = new Headers ( ) ;
134131 headers . append ( 'Accept' , 'text/mapml' ) ;
@@ -157,7 +154,7 @@ export class MapLayer extends HTMLElement {
157154 content ,
158155 {
159156 mapprojection : this . parentElement . projection ,
160- opacity : opacity_value
157+ opacity : this . opacity
161158 }
162159 ) ;
163160 resolve ( ) ;
@@ -171,7 +168,7 @@ export class MapLayer extends HTMLElement {
171168 }
172169 this . _layer = M . mapMLLayer ( null , this , null , {
173170 mapprojection : this . parentElement . projection ,
174- opacity : opacity_value
171+ opacity : this . opacity
175172 } ) ;
176173 resolve ( ) ;
177174 }
@@ -184,6 +181,7 @@ export class MapLayer extends HTMLElement {
184181 if ( e . type === 'changeprojection' ) {
185182 this . src = e . detail . href ;
186183 } else {
184+ console . log ( e ) ;
187185 this . dispatchEvent (
188186 new CustomEvent ( 'error' , { detail : { target : this } } )
189187 ) ;
@@ -292,28 +290,21 @@ export class MapLayer extends HTMLElement {
292290 break ;
293291 case 'opacity' :
294292 if ( oldValue !== newValue && this . _layer ) {
293+ this . _opacity = newValue ;
295294 this . _layer . changeOpacity ( newValue ) ;
296295 }
297296 break ;
298297 case 'src' :
299298 if ( oldValue !== newValue && this . _layer ) {
300- this . _reload ( ) ;
299+ this . _onRemove ( ) ;
300+ if ( this . isConnected ) {
301+ this . _onAdd ( ) ;
302+ }
301303 // the original inline content will not be removed
302304 // but has NO EFFECT and works as a fallback
303305 }
304306 }
305307 }
306- // re-load the layer element when the src attribute is changed
307- _reload ( ) {
308- let oldOpacity = this . opacity ;
309- // go through the same sequence as if the layer had been removed from
310- // the DOM and re-attached with a new URL source.
311- this . _onRemove ( ) ;
312- if ( this . isConnected ) {
313- this . _onAdd ( ) ;
314- }
315- this . opacity = oldOpacity ;
316- }
317308 _validateDisabled ( ) {
318309 setTimeout ( ( ) => {
319310 let layer = this . _layer ,
0 commit comments