Skip to content

Commit

Permalink
Remove prefers-map-content hardcoded demo hack tbd broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
prushforth committed Dec 13, 2024
1 parent d5a356b commit bb19e81
Showing 1 changed file with 0 additions and 27 deletions.
27 changes: 0 additions & 27 deletions src/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ export class BaseLayerElement extends HTMLElement {
// this._opacity is used to record the current opacity value (with or without updates),
// the initial value of this._opacity should be set as opacity attribute value, if exists, or the default value 1.0
this._opacity = this.opacity || 1.0;
this._renderingMapContent = M.options.contentPreference;
this.attachShadow({ mode: 'open' });
}
disconnectedCallback() {
Expand Down Expand Up @@ -297,7 +296,6 @@ export class BaseLayerElement extends HTMLElement {
.then(() => {
// may throw:
this.selectAlternateOrChangeProjection();
this.checkForPreferredContent();
})
.then(() => {
this._layer = mapMLLayer(new URL(this.src, base).href, this, {
Expand Down Expand Up @@ -335,7 +333,6 @@ export class BaseLayerElement extends HTMLElement {
.then(() => {
// may throw:
this.selectAlternateOrChangeProjection();
this.checkForPreferredContent();
})
.then(() => {
this._layer = mapMLLayer(null, this, {
Expand Down Expand Up @@ -374,13 +371,6 @@ export class BaseLayerElement extends HTMLElement {
);
this.parentElement.projection = e.cause.mapprojection;
}
} else if (e.message === 'findmatchingpreferredcontent') {
if (e.cause.href) {
console.log(
'Changing layer to matching preferred content at: ' + e.cause.href
);
this.src = e.cause.href;
}
} else if (e.message === 'Failed to fetch') {
// cut short whenReady with the _fetchError property
this._fetchError = true;
Expand Down Expand Up @@ -429,23 +419,6 @@ export class BaseLayerElement extends HTMLElement {
}
}

checkForPreferredContent() {
let mapml = this.src ? this.shadowRoot : this;
let availablePreferMapContents = mapml.querySelector(
`map-link[rel="style"][media="prefers-map-content=${this._renderingMapContent}"][href]`
);
if (availablePreferMapContents) {
// resolve href
let url = new URL(
availablePreferMapContents.getAttribute('href'),
availablePreferMapContents.getBase()
).href;
throw new Error('findmatchingpreferredcontent', {
cause: { href: url }
});
}
}

copyRemoteContentToShadowRoot(mapml) {
let shadowRoot = this.shadowRoot;
// get the map-meta[name=projection/cs/extent/zoom] from map-head of remote mapml, attach them to the shadowroot
Expand Down

0 comments on commit bb19e81

Please sign in to comment.