Skip to content

Commit

Permalink
Make it so that <map-extent>.getMeta looks for name=cs type metas.
Browse files Browse the repository at this point in the history
Revert change to <map-feature>.getFallBackCS to the extent that it once
again relies on <map-extent>.getMeta (which was updated to work for this
use case).
  • Loading branch information
prushforth committed Apr 25, 2024
1 parent fc072e2 commit b53c497
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/map-extent.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export class MapExtent extends HTMLElement {
}
getMeta(metaName) {
let name = metaName.toLowerCase();
if (name !== 'extent' && name !== 'zoom') return;
if (name !== 'extent' && name !== 'zoom' && name !== 'cs') return;
return this.parentLayer.src
? this.querySelector(`:scope > map-meta[name=${name}]`) ||
this.parentLayer.shadowRoot.querySelector(
Expand Down
30 changes: 11 additions & 19 deletions src/map-feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,30 +285,22 @@ export class MapFeature extends HTMLElement {
// native cs: used by FeatureLayer._geometryToLayer(...),
// the fallback cs for map-geometry if its cs attribute is not specified
_getFallbackCS() {
let csMeta, cs;
let csMeta;
if (this._parentEl.nodeName === 'MAP-LINK') {
// feature attaches to link's shadow
csMeta = this._parentEl.shadowRoot.querySelector(
'map-meta[name=cs][content]'
);
let linkCS = this._parentEl._templateVars.values.find(
(input) => input.units
)?.units;
cs = csMeta
? M._metaContentToObject(csMeta.getAttribute('content')).content
: linkCS
? linkCS
: 'gcrs';
// feature attaches to link's shadow root
csMeta =
this._parentEl.shadowRoot.querySelector('map-meta[name=cs][content]') ||
this._parentEl.parentElement.getMeta('cs');
} else {
let layerEl = this.getLayerEl();
csMeta = layerEl.src
? layerEl.shadowRoot.querySelector('map-meta[name=cs]')
: layerEl.querySelector('map-meta[name=cs]');
cs = csMeta
? M._metaContentToObject(csMeta.getAttribute('content')).content
: 'gcrs';
? layerEl.shadowRoot.querySelector('map-meta[name=cs][content]')
: layerEl.querySelector('map-meta[name=cs][content]');
}
return cs;
// even here we could make an effort to use the tref variables to determine
// the coordinate system of the response - would only work with WMS, I think
// the fallback 'gcrs' SHOULD be specified by the MapML spec
return csMeta ? M._metaContentToObject(csMeta.getAttribute('content')).content : 'gcrs';
}

// Util functions:
Expand Down

0 comments on commit b53c497

Please sign in to comment.