You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As pointed by @yhy0217 When removing a map-extent from a single layer in a map, the other map-extents should be used to calculate the projection of the layer.
We devised an early method (similar to determineLayerProjection, which should be merged to this method) for layer.js to help with this, which is called from map-extent disconnected Callback and can also be called from the layer disconnectedcallback:
// update the layer projection based on it's children, used if map-meta is appended or map-extents are removedvalidateLayerProjection(){letmeta=this.shadowRoot
? this.shadowRoot.querySelector('map-meta[name=projection][content]')
: this.querySelector('map-meta[name=projection][content]');// if map-meta for project exists use it primarilyif(meta){letmetaProjection=M._metaContentToObject(meta.getAttribute('content')).content;if(metaProjection.toUpperCase()!==this._layer._properties.projection.toUpperCase()){this._layer._properties.projection=metaProjection.toUpperCase();}}else{// otherwise use map-extents to check if projection can be updatedletextents=this.shadowRoot
? this.shadowRoot.querySelectorAll('map-extent')
: this.querySelectorAll('map-extent');letmatch=true;for(leti=0;i<extents.length;i++){if(extents[i].units.toUpperCase()!==extents[0].units.toUpperCase()){match=false;break;}}// if all map-extents have same projection, update layer projectionif(match){this._layer._properties.projection=extents[0].units;}else{// change projection to map-projection, similar to what is done in initialization// in determineLayerProjectionthis._layer._properties.projection=this._layer.options.mapprojection;}}// check if only layer for mapml-viewer and to update the map projection if neededif(this._layer._properties.projection!==this._layer.options.mapprojection&&this.parentElement.layers.length===1){this.parentElement.projection=this._layer._properties.projection;}}
Steps to reproduce, paste the following to https://maps4html.org/web-map-doc/demo/sandbox/ and remove the OSMTILE map-extent, expected outcome should be that the map changes projection to CBMTILE to display the CBMTILE map-extent as it is the only layer in the map:
As pointed by @yhy0217 When removing a map-extent from a single layer in a map, the other map-extents should be used to calculate the projection of the layer.
Relevant to #911
We devised an early method (similar to determineLayerProjection, which should be merged to this method) for layer.js to help with this, which is called from map-extent disconnected Callback and can also be called from the layer disconnectedcallback:
Steps to reproduce, paste the following to https://maps4html.org/web-map-doc/demo/sandbox/ and remove the OSMTILE
map-extent
, expected outcome should be that the map changes projection to CBMTILE to display the CBMTILE map-extent as it is the only layer in the map:The text was updated successfully, but these errors were encountered: