Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mo-analameira
Copy link
Contributor

@mo-analameira mo-analameira commented Jan 2, 2025

This PR is meant to fix the reload tile layer wms bug and add support for tile layer wms standard attribute changes (grid options not included).

this.reloadLayer();
}
if (name === "options" && oldValue !== newValue && this.layer) {
this.layer.setParams(newValue);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should newValue parsed with JSON.parse?

Copy link
Contributor Author

@mo-analameira mo-analameira Jan 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup! only noticed it when, while testing options attribute mutations in the app, the WMS requests being made were a little off :P (it's the first force push... bad habit I know)

@mo-analameira mo-analameira force-pushed the fix/change-options-attribute-change-handling branch from d4e855e to 6814fc7 Compare January 2, 2025 18:20
@mo-analameira mo-analameira force-pushed the fix/change-options-attribute-change-handling branch from 6814fc7 to 0ed3cfd Compare January 2, 2025 18:29
});

const standardOptions = parse(schema, this);
const nonStandardOptionsElement = this.getAttribute("options");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nonStandardOptionsElement feels like the wrong variable name, something like text or attr may be better suffixes

reloadLayer() {
if (this.layer) {
this.layer.remove();
_parseNonStandardOptions(nonStandardOptionsElement) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter to this function is either string or null. Perhaps optionsText would be a better variable name. Not perfect, but better :-)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or keep it as an Element and move the .getAttribute("options") call inside it.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or even, since it's a private method and the only positional argument is this, remove the positional argument altogether.

// E.g. calling code
let opts = this._parseNonStandardOptions()

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although, I forget how functions bind parent caller objects in JS ;-)

The this pointer is a mysterious mechanism. Although, probably ok in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

closures?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Or keep it as an Element and move the .getAttribute("options") call inside it." I don't need getAttribute in the change callback that also uses the method, that's why I left it out

Copy link
Owner

@andrewgryan andrewgryan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to fix the double-map lifecycle issue and adds observed attrs. Good work!

@andrewgryan andrewgryan merged commit 088ccd1 into andrewgryan:master Jan 3, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants