@@ -1534,9 +1534,7 @@ export var MapMLLayer = L.Layer.extend({
1534
1534
getExtentLayerControls ( ) ;
1535
1535
layer . _styles = getAlternateStyles ( ) ;
1536
1536
layer . _validateExtent ( ) ;
1537
- if ( this . responseXML ) {
1538
- attachToLayer . call ( layer ) ;
1539
- }
1537
+ copyRemoteContentToShadowRoot ( ) ;
1540
1538
// update controls if needed based on mapml-viewer controls/controlslist attribute
1541
1539
if ( layer . _layerEl . parentElement ) {
1542
1540
// if layer does not have a parent Element, do not need to set Controls
@@ -1676,9 +1674,14 @@ export var MapMLLayer = L.Layer.extend({
1676
1674
layer . _title = mapml . getAttribute ( 'label' ) . trim ( ) ;
1677
1675
}
1678
1676
}
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
+ }
1680
1683
let mapml = xhr . responseXML ,
1681
- shadowRoot = this . _layerEl . shadowRoot ;
1684
+ shadowRoot = layer . _layerEl . shadowRoot ;
1682
1685
let elements = mapml . children [ 0 ] . children [ 1 ] . children ;
1683
1686
if ( elements ) {
1684
1687
let baseURL = mapml . children [ 0 ] . children [ 0 ]
@@ -1781,7 +1784,7 @@ export var MapMLLayer = L.Layer.extend({
1781
1784
}
1782
1785
} ,
1783
1786
// 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.
1785
1788
getProjection : function ( ) {
1786
1789
if ( ! this . _extent ) {
1787
1790
return ;
0 commit comments