You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #2385 [Map] Make UX Map compatible with Live Components (and some internal things) (Kocal)
This PR was squashed before being merged into the 2.x branch.
Discussion
----------
[Map] Make UX Map compatible with Live Components (and some internal things)
Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | yes <!-- please update src/**/CHANGELOG.md files -->
| Issues | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License | MIT
Here’s a corrected and polished version of your text:
---
Hi! 😊
This PR enhances the UX Map to be compatible with Live Components, allowing you to interact with the `Map` directly from your PHP code. You can perform actions and see your map update in real-time from the front-end!
To achieve this, I had to refactor and improve several areas:
1. Due to the hydration and de-hydration processes of Live Components, I ensured that the `toArray` and new `fromArray` methods for `Map`, `Marker`, and all other value objects could rebuild an equivalent object accurately (e.g., `$marker == Marker::fromArray($marker->toArray())`).
2. Since Stimulus monitors value changes, it wasn’t efficient to store everything in a single large `view` object containing `zoom`, `center`, `markers`, etc. These properties were split into individual values to improve performance.
3. Before rendering the map, an ``@id`` is now automatically computed for each `Marker` and `Polygon` definition. This optimization makes rendering significantly more efficient, avoiding the need to remove and re-render all markers or polygons (and avoiding a visual glitch aswell).
https://github.com/user-attachments/assets/c151e64c-7321-46d3-a5c6-cfeaf57beb47https://github.com/user-attachments/assets/ffb12035-a0c3-48b3-afb7-ddf2c24c318a
Commits
-------
74d937a Apply `@smnandre`'s suggestions from code review
7d30e20 [Map] Listen for zoom, center, markers and polygons changes, and update JS tests
aae9ddd [Map] Complete and simplify the normalization/denormalization process of Map's value objects, add MapOptionsNormalizer
4744d3d [Map] Add "fromArray" methods to options and other DTO, make "*Array" methods internal
8ab164b [Map] Split "view" attribute into multiple attributes
0 commit comments