Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot disable startIcon or endIcon #158

Closed
MarsupialFan opened this issue Aug 26, 2024 · 1 comment
Closed

Cannot disable startIcon or endIcon #158

MarsupialFan opened this issue Aug 26, 2024 · 1 comment

Comments

@MarsupialFan
Copy link

According to the Configuring markers section in README.md:

startIcon is used for ...
You can also override any of those to null to disable the corresponding marker altogether.

However, when I set it to null,

        const options = {
            async: true,
            markers: {
                startIcon: null,
            },
        };

I get the following error message:

TypeError: Object.entries requires that input parameter not be null or undefined

I suspect this might be due to lines 298-299 of gpx.js:

      } else if (typeof(value) === 'object') {
        markers[key] = this._prepare_markers(value);

Since the key (startIcon or endIcon) doesn't match the previous if's, and since null is an object, the code calls _prepare_markers recursively with null as the markers parameter, and then Object.entries(markers) barfs.

Should the code refrain from making the recursive call if value is null?

[On a separate note, this issue (from 4 years ago) suggests to set startIconUrl to null, but this no longer works either.]

Thank you!

@mpetazzoni
Copy link
Owner

Thanks! I didn't realize type(null) would be object 😁 Typical Javascript gotcha! Fixed and released in v2.1.2.

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

No branches or pull requests

2 participants