@@ -48,7 +48,7 @@ export class MapLayer extends HTMLElement {
48
48
}
49
49
50
50
get opacity ( ) {
51
- return this . _layer . _container . style . opacity || this . _layer . options . opacity ;
51
+ return this . _opacity ;
52
52
}
53
53
54
54
set opacity ( val ) {
@@ -126,9 +126,6 @@ export class MapLayer extends HTMLElement {
126
126
{ once : true }
127
127
) ;
128
128
let base = this . baseURI ? this . baseURI : document . baseURI ;
129
- let opacity_value = this . hasAttribute ( 'opacity' )
130
- ? this . getAttribute ( 'opacity' )
131
- : '1.0' ;
132
129
133
130
const headers = new Headers ( ) ;
134
131
headers . append ( 'Accept' , 'text/mapml' ) ;
@@ -157,7 +154,7 @@ export class MapLayer extends HTMLElement {
157
154
content ,
158
155
{
159
156
mapprojection : this . parentElement . projection ,
160
- opacity : opacity_value
157
+ opacity : this . opacity
161
158
}
162
159
) ;
163
160
resolve ( ) ;
@@ -171,7 +168,7 @@ export class MapLayer extends HTMLElement {
171
168
}
172
169
this . _layer = M . mapMLLayer ( null , this , null , {
173
170
mapprojection : this . parentElement . projection ,
174
- opacity : opacity_value
171
+ opacity : this . opacity
175
172
} ) ;
176
173
resolve ( ) ;
177
174
}
@@ -184,6 +181,7 @@ export class MapLayer extends HTMLElement {
184
181
if ( e . type === 'changeprojection' ) {
185
182
this . src = e . detail . href ;
186
183
} else {
184
+ console . log ( e ) ;
187
185
this . dispatchEvent (
188
186
new CustomEvent ( 'error' , { detail : { target : this } } )
189
187
) ;
@@ -292,28 +290,21 @@ export class MapLayer extends HTMLElement {
292
290
break ;
293
291
case 'opacity' :
294
292
if ( oldValue !== newValue && this . _layer ) {
293
+ this . _opacity = newValue ;
295
294
this . _layer . changeOpacity ( newValue ) ;
296
295
}
297
296
break ;
298
297
case 'src' :
299
298
if ( oldValue !== newValue && this . _layer ) {
300
- this . _reload ( ) ;
299
+ this . _onRemove ( ) ;
300
+ if ( this . isConnected ) {
301
+ this . _onAdd ( ) ;
302
+ }
301
303
// the original inline content will not be removed
302
304
// but has NO EFFECT and works as a fallback
303
305
}
304
306
}
305
307
}
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
- }
317
308
_validateDisabled ( ) {
318
309
setTimeout ( ( ) => {
319
310
let layer = this . _layer ,
0 commit comments