MCPcopy Index your code
hub / github.com/Maps4HTML/MapML.js / connectedCallback

Method connectedCallback

src/map-tile.js:106–135  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

104 super.setAttribute(name, value);
105 }
106 async connectedCallback() {
107 // initialization is done in connectedCallback, attribute initialization
108 // calls (which happen first) are effectively ignored, so we should be able
109 // to rely on them being all correctly set by this time e.g. zoom, row, col
110 // all now have a value that together identify this tiled bit of space
111 // row,col,zoom can't / shouldn't change
112 /* jshint ignore:start */
113 this.#initialZoom = this.hasAttribute('zoom')
114 ? +this.getAttribute('zoom')
115 : this.getMapEl().zoom;
116 this.#initialRow = this.hasAttribute('row') ? +this.getAttribute('row') : 0;
117 this.#initialCol = this.hasAttribute('col') ? +this.getAttribute('col') : 0;
118 this.#hasConnected = true;
119 /* jshint ignore:end */
120 // Get parent element to determine how to handle the tile
121 // Need to handle shadow DOM correctly like map-feature does
122 this._parentEl =
123 this.parentNode.nodeName === 'MAP-LAYER' ||
124 this.parentNode.nodeName === 'LAYER-' ||
125 this.parentNode.nodeName === 'MAP-LINK'
126 ? this.parentNode
127 : this.parentNode.host;
128
129 // in the case of <map-tile> that is rendered but never connected, this won't
130 // matter, but it speeds up rendering for tiles that go through here...
131 const imgObj = new Image();
132 imgObj.src = this.getAttribute('src');
133
134 await this._createOrGetTileLayer();
135 }
136
137 disconnectedCallback() {
138 // Decrement layer registry count

Callers

nothing calls this directly

Calls 3

getAttributeMethod · 0.95
getMapElMethod · 0.95
_createOrGetTileLayerMethod · 0.95

Tested by

no test coverage detected