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

Fix multiple maps not rendering #92

Merged

Conversation

nsass24
Copy link
Contributor

@nsass24 nsass24 commented Sep 20, 2024

This PR aims to fix #89

Changes:

  • Refactor LAYERS:

    • Replaced the global LAYERS object with a getLayers() function that returns a new instance of map layers each time it is called.
    • This ensures that every map has its own set of layer objects to prevent tile loading conflicts caused by shared state.
  • Exported LAYER_NAMES:

    • Refactored how the map layer names are used in the PanelPlugin options to ensure compatibility.
    • The LAYER_NAMES array was introduced to maintain the list of available layer names separately from the actual layer objects.
  • Updated TrackMapPanel:

    • Modified TrackMapPanel.tsx to use the getLayers() function, ensuring each map receives its own set of layers, solving the issue of race conditions in tile rendering.

Files Modified:

  • src/TrackMapPanel.tsx
  • src/layers.ts
  • src/module.ts

Steps to Reproduce (Before the fix):

  1. Use the plugin in more than one panel in a dashboard.
  2. Observe that only the one of the panels map will load when all the panels have the same default map (If maps have different default maps the issue doesn't occur).

…tile rendering conflicts

- Replaced global `LAYERS` object with a `getLayers()` function to provide fresh instances for each map.
- Exported `LAYER_NAMES` for use in plugin options to maintain compatibility with layer selection.
- Updated `TrackMapPanel` to use instance-specific layers via `getLayers()` to prevent map rendering conflicts due to shared state.
- Modified affected files: `TrackMapPanel.tsx`, `layers.ts`, `module.ts`.
@pR0Ps
Copy link
Owner

pR0Ps commented Sep 22, 2024

Thanks for taking care of this, I'll devote some time to properly review it soon

@pR0Ps pR0Ps merged commit 70a5971 into pR0Ps:master Oct 9, 2024
1 of 2 checks passed
pR0Ps pushed a commit that referenced this pull request Oct 9, 2024
…conflicts (#92)

- Replaced global `LAYERS` object with a `getLayers()` function to provide fresh instances for each map.
- Exported `LAYER_NAMES` for use in plugin options to maintain compatibility with layer selection.
- Updated `TrackMapPanel` to use instance-specific layers via `getLayers()` to prevent map rendering conflicts due to shared state.

Fixes #89
@pR0Ps
Copy link
Owner

pR0Ps commented Oct 9, 2024

Merged, thanks for tracking down this issue!

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.

With 3.0.0 only one Map will show Images
2 participants