Skip to content

Commit

Permalink
Refactor: MapMLLayer._extent -> MapMLLayer._properties
Browse files Browse the repository at this point in the history
  • Loading branch information
prushforth committed Jul 20, 2023
1 parent 5e184e3 commit d2b6e72
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 157 deletions.
25 changes: 15 additions & 10 deletions src/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,29 +219,34 @@ export class MapLayer extends HTMLElement {
let type = layerTypes[j];
if (this.checked && layer[type]) {
if (type === '_templatedLayer') {
for (let i = 0; i < layer._extent._mapExtents.length; i++) {
for (let i = 0; i < layer._properties._mapExtents.length; i++) {
for (
let j = 0;
j <
layer._extent._mapExtents[i].templatedLayer._templates
layer._properties._mapExtents[i].templatedLayer._templates
.length;
j++
) {
if (
layer._extent._mapExtents[i].templatedLayer._templates[j]
.rel === 'query'
layer._properties._mapExtents[i].templatedLayer
._templates[j].rel === 'query'
)
continue;
total++;
layer._extent._mapExtents[i].removeAttribute('disabled');
layer._extent._mapExtents[i].disabled = false;
layer._properties._mapExtents[i].removeAttribute(
'disabled'
);
layer._properties._mapExtents[i].disabled = false;
if (
!layer._extent._mapExtents[i].templatedLayer._templates[j]
.layer.isVisible
!layer._properties._mapExtents[i].templatedLayer
._templates[j].layer.isVisible
) {
count++;
layer._extent._mapExtents[i].setAttribute('disabled', '');
layer._extent._mapExtents[i].disabled = true;
layer._properties._mapExtents[i].setAttribute(
'disabled',
''
);
layer._properties._mapExtents[i].disabled = true;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/map-feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export class MapFeature extends HTMLElement {
layerEl.querySelectorAll('map-feature').length === 1
) {
// if the map-feature is added to an empty layer, fire extentload to create vector layer
// must re-run _initialize of MapMLLayer.js to re-set layer._extent (layer._extent is null for an empty layer)
// must re-run _initialize of MapMLLayer.js to re-set layer._properties (layer._properties is null for an empty layer)
this._layer._initialize(layerEl);
this._layer.fire('extentload');
}
Expand Down
12 changes: 6 additions & 6 deletions src/mapml/control/LayerControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,20 @@ export var LayerControl = L.Control.Layers.extend({
}
// check if an extent is disabled and disable it
if (
this._layers[i].layer._extent &&
this._layers[i].layer._extent._mapExtents
this._layers[i].layer._properties &&
this._layers[i].layer._properties._mapExtents
) {
for (
let j = 0;
j < this._layers[i].layer._extent._mapExtents.length;
j < this._layers[i].layer._properties._mapExtents.length;
j++
) {
let input =
this._layers[i].layer._extent._mapExtents[j].extentAnatomy,
this._layers[i].layer._properties._mapExtents[j].extentAnatomy,
label = input.getElementsByClassName('mapml-layer-item-name')[0];
if (
this._layers[i].layer._extent._mapExtents[j].disabled &&
this._layers[i].layer._extent._mapExtents[j].checked
this._layers[i].layer._properties._mapExtents[j].disabled &&
this._layers[i].layer._properties._mapExtents[j].checked
) {
label.style.fontStyle = 'italic';
input.disabled = true;
Expand Down
2 changes: 1 addition & 1 deletion src/mapml/handlers/QueryHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export var QueryHandler = L.Handler.extend({
_query(e, layer) {
var zoom = e.target.getZoom(),
map = this._map,
crs = layer._extent.crs, // the crs for each extent would be the same
crs = layer._properties.crs, // the crs for each extent would be the same
tileSize = map.options.crs.options.crs.tile.bounds.max.x,
container = layer._container,
popupOptions = {
Expand Down
Loading

0 comments on commit d2b6e72

Please sign in to comment.