()
| 240 | this._changeHandler = this._handleChange.bind(this); |
| 241 | } |
| 242 | async connectedCallback() { |
| 243 | // this.parentNode.host returns the map-layer element when parentNode is |
| 244 | // the shadow root |
| 245 | this.parentLayer = this.getLayerEl(); |
| 246 | if ( |
| 247 | this.hasAttribute('data-moving') || |
| 248 | this.parentLayer.hasAttribute('data-moving') |
| 249 | ) |
| 250 | return; |
| 251 | this.mapEl = this.getMapEl(); |
| 252 | await this.mapEl.whenProjectionDefined(this.units).catch(() => { |
| 253 | throw new Error('Undefined projection:' + this.units); |
| 254 | }); |
| 255 | // when projection is changed, the parent map-layer._layer is created (so whenReady is fulfilled) but then removed, |
| 256 | // then the map-extent disconnectedCallback will be triggered by map-layer._onRemove() (clear the shadowRoot) |
| 257 | // even before connectedCallback is finished |
| 258 | // in this case, the microtasks triggered by the fulfillment of the removed MapLayer should be stopped as well |
| 259 | // !this.isConnected <=> the disconnectedCallback has run before |
| 260 | if (!this.isConnected) return; |
| 261 | /* jshint ignore:start */ |
| 262 | this.#hasConnected = true; |
| 263 | /* jshint ignore:end */ |
| 264 | this._map = this.mapEl._map; |
| 265 | this.parentLayer.addEventListener('map-change', this._changeHandler); |
| 266 | this.mapEl.addEventListener('map-projectionchange', this._changeHandler); |
| 267 | // this._opacity is used to record the current opacity value (with or without updates), |
| 268 | // the initial value of this._opacity should be set as opacity attribute value, if exists, or the default value 1.0 |
| 269 | this._opacity = this.opacity || 1.0; |
| 270 | this._extentLayer = mapExtentLayer({ |
| 271 | opacity: this.opacity, |
| 272 | crs: M[this.units], |
| 273 | zIndex: this.position, |
| 274 | extentEl: this |
| 275 | }); |
| 276 | // this._layerControlHTML is the fieldset for the extent in the LayerControl |
| 277 | this._layerControlHTML = this._createLayerControlExtentHTML(); |
| 278 | this._calculateBounds(); |
| 279 | // instead of children using parents' whenReady which can be cyclic, |
| 280 | // when this element is ready, run stuff that is only available after |
| 281 | // initialization |
| 282 | this._runMutationObserver(this.children); |
| 283 | // make sure same thing happens when children are added |
| 284 | this._bindMutationObserver(); |
| 285 | } |
| 286 | /* |
| 287 | * Set up a function to watch additions of child elements of map-extent |
| 288 | * and to invoke desired side effects of those additions via |
nothing calls this directly
no test coverage detected