@@ -1534,9 +1534,7 @@ export var MapMLLayer = L.Layer.extend({
15341534 getExtentLayerControls ( ) ;
15351535 layer . _styles = getAlternateStyles ( ) ;
15361536 layer . _validateExtent ( ) ;
1537- if ( this . responseXML ) {
1538- attachToLayer . call ( layer ) ;
1539- }
1537+ copyRemoteContentToShadowRoot ( ) ;
15401538 // update controls if needed based on mapml-viewer controls/controlslist attribute
15411539 if ( layer . _layerEl . parentElement ) {
15421540 // if layer does not have a parent Element, do not need to set Controls
@@ -1676,9 +1674,14 @@ export var MapMLLayer = L.Layer.extend({
16761674 layer . _title = mapml . getAttribute ( 'label' ) . trim ( ) ;
16771675 }
16781676 }
1679- function attachToLayer ( ) {
1677+ function copyRemoteContentToShadowRoot ( ) {
1678+ // only run when content is loaded from network, puts features etc
1679+ // into layer shadow root
1680+ if ( ! xhr ) {
1681+ return ;
1682+ }
16801683 let mapml = xhr . responseXML ,
1681- shadowRoot = this . _layerEl . shadowRoot ;
1684+ shadowRoot = layer . _layerEl . shadowRoot ;
16821685 let elements = mapml . children [ 0 ] . children [ 1 ] . children ;
16831686 if ( elements ) {
16841687 let baseURL = mapml . children [ 0 ] . children [ 0 ]
@@ -1781,7 +1784,7 @@ export var MapMLLayer = L.Layer.extend({
17811784 }
17821785 } ,
17831786 // a layer must share a projection with the map so that all the layers can
1784- // be overlayed in one coordinate space. WGS84 is a 'wildcard', sort of.
1787+ // be overlayed in one coordinate space.
17851788 getProjection : function ( ) {
17861789 if ( ! this . _extent ) {
17871790 return ;
0 commit comments