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

[Map] Make UX Map compatible with Live Components (and some internal things) #2385

Open
wants to merge 4 commits into
base: 2.x
Choose a base branch
from

Conversation

Kocal
Copy link
Member

@Kocal Kocal commented Nov 17, 2024

Q A
Bug fix? no
New feature? yes
Issues Fix #...
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).
Enregistrement.de.l.ecran.2024-11-17.a.10.30.54-2.mov
Enregistrement.de.l.ecran.2024-11-17.a.10.28.15-2.mov

@carsonbot carsonbot added Feature New Feature Map Status: Needs Review Needs to be reviewed labels Nov 17, 2024
Copy link

github-actions bot commented Nov 17, 2024

📊 Packages dist files size difference

Thanks for the PR! Here is the difference in size of the packages dist files between the base branch and the PR.
Please review the changes and make sure they are expected.

FileBefore (Size / Gzip)After (Size / Gzip)
Map
abstract_map_controller.d.ts 3 kB / 741 B 3.31 kB+10% 📈 / 821 B+11% 📈
abstract_map_controller.js 1.88 kB / 610 B 3.29 kB+75% 📈 / 847 B+39% 📈
Map (Bridge Google)
map_controller.d.ts 2.07 kB / 729 B 2.19 kB+6% 📈 / 733 B+1% 📈
map_controller.js 7.07 kB / 1.67 kB 8.76 kB+24% 📈 / 1.96 kB+17% 📈
Map (Bridge Leaflet)
map_controller.d.ts 1.31 kB / 544 B 1.57 kB+20% 📈 / 579 B+6% 📈
map_controller.js 5.52 kB / 1.77 kB 7.25 kB+31% 📈 / 2.07 kB+17% 📈

@Kocal Kocal force-pushed the imp-map-split-view-attrs branch 2 times, most recently from 09a20f7 to 63dec0f Compare November 17, 2024 09:47
… of Map's value objects, add MapOptionsNormalizer
@Kocal Kocal force-pushed the imp-map-split-view-attrs branch 3 times, most recently from f0e60a9 to 00fc2d4 Compare November 17, 2024 10:15
@Kocal
Copy link
Member Author

Kocal commented Nov 17, 2024

Note: Usages and examples can be a bit limited for the moment, but for a next PR I would like to add more methods like getZoom() or removeMarker() (...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New Feature Map Status: Needs Review Needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants