Skip to content

Commit 4314a86

Browse files
author
Peter Rushforth
committed
Adjust to get tests passing, maybe
1 parent 06660b3 commit 4314a86

File tree

6 files changed

+24
-783
lines changed

6 files changed

+24
-783
lines changed

src/layer.js

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -472,16 +472,6 @@ export class BaseLayerElement extends HTMLElement {
472472
* child element processing.
473473
*/
474474
_runMutationObserver(elementsGroup) {
475-
const _addFeatureToMapMLVectors = (feature) => {
476-
this.whenReady().then(() => {
477-
// the layer extent must change as features are added, this.extent
478-
// property only recalculates the bounds and zoomBounds when .bounds
479-
// doesn't exist, so delete it to ensure that the extent is reset
480-
delete this._layer.bounds;
481-
// Features now manage themselves through connectedCallback and MapFeatureLayer
482-
// This method now only handles extent recalculation
483-
});
484-
};
485475
const _addStylesheetLink = (mapLink) => {
486476
this.whenReady().then(() => {
487477
this._layer.renderStyles(mapLink);
@@ -513,9 +503,6 @@ export class BaseLayerElement extends HTMLElement {
513503
for (let i = 0; i < elementsGroup.length; ++i) {
514504
let element = elementsGroup[i];
515505
switch (element.nodeName) {
516-
case 'MAP-FEATURE':
517-
_addFeatureToMapMLVectors(element);
518-
break;
519506
case 'MAP-LINK':
520507
if (element.link && !element.link.isConnected)
521508
_addStylesheetLink(element);
@@ -598,16 +585,19 @@ export class BaseLayerElement extends HTMLElement {
598585
opacity: window.getComputedStyle(this).opacity
599586
});
600587
// make sure the Leaflet layer has a reference to the map
601-
this._layer._map = this.parentNode._map;
588+
// this is causing problems with LayerGroup, as Leaflet uses the _map property
589+
// to determine if a LayerGroup's child layers should have their onAdd invoked
590+
// (be added to the map)
591+
// this._layer._map = this.parentNode._map;
602592

603593
if (this.checked) {
604-
this._layer.addTo(this._layer._map);
594+
this._layer.addTo(this.parentNode._map);
595+
// toggle the this.disabled attribute depending on whether the layer
596+
// is: same prj as map, within view/zoom of map
605597
}
598+
this.parentNode._map.on('moveend layeradd', this._validateDisabled, this);
606599

607600
this._layer.on('add remove', this._validateDisabled, this);
608-
// toggle the this.disabled attribute depending on whether the layer
609-
// is: same prj as map, within view/zoom of map
610-
this._layer._map.on('moveend layeradd', this._validateDisabled, this);
611601

612602
if (this.parentNode._layerControl)
613603
this._layerControl = this.parentNode._layerControl;

src/map-feature.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@ export class HTMLFeatureElement extends HTMLElement {
172172
// used for fallback zoom getter for static features
173173
this._initialZoom = this.getMapEl().zoom;
174174
this._parentEl =
175-
this.parentNode.nodeName.toUpperCase() === 'MAP-LAYER' ||
176-
this.parentNode.nodeName.toUpperCase() === 'LAYER-' ||
177-
this.parentNode.nodeName.toUpperCase() === 'MAP-LINK'
175+
this.parentNode.nodeName === 'MAP-LAYER' ||
176+
this.parentNode.nodeName === 'LAYER-' ||
177+
this.parentNode.nodeName === 'MAP-LINK'
178178
? this.parentNode
179179
: this.parentNode.host;
180180
if (
@@ -183,8 +183,9 @@ export class HTMLFeatureElement extends HTMLElement {
183183
)
184184
return;
185185
if (
186-
this._parentEl.nodeName === 'MAP-LINK' ||
187-
this._parentEl.nodeName === 'MAP-LAYER'
186+
this.parentNode.nodeName === 'MAP-LAYER' ||
187+
this.parentNode.nodeName === 'LAYER-' ||
188+
this.parentNode.nodeName === 'MAP-LINK'
188189
) {
189190
this._createOrGetFeatureLayer();
190191
}

src/mapml/features/geometry.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FeatureGroup, LayerGroup, DomUtil, DomEvent, bounds } from 'leaflet';
1+
import { FeatureGroup, DomUtil, DomEvent, bounds } from 'leaflet';
22

33
import { Path, path } from './path.js';
44

@@ -15,7 +15,7 @@ export var Geometry = FeatureGroup.extend({
1515
options
1616
);
1717

18-
LayerGroup.prototype.initialize.call(this, layers, options);
18+
FeatureGroup.prototype.initialize.call(this, layers, options);
1919
this._featureEl = this.options.mapmlFeature;
2020

2121
this.layerBounds = options.layerBounds;
@@ -55,7 +55,7 @@ export var Geometry = FeatureGroup.extend({
5555
},
5656

5757
onAdd: function (map) {
58-
LayerGroup.prototype.onAdd.call(this, map);
58+
FeatureGroup.prototype.onAdd.call(this, map);
5959
this.updateInteraction();
6060
},
6161

0 commit comments

Comments
 (0)