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][Google] Add maxZoom to GoogleOptions #2520

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

Conversation

nina-alin
Copy link

Q A
Bug fix? no
New feature? yes
Issues none
License MIT

I added the "maxZoom" option to the Symfony UX Google Map package. I needed it for a project, so I thought it would be a good addition.

This is my first time contributing to Symfony, so please let me know if I made any mistakes.

I'm also unsure if you're planning to add more GoogleOptions in the future. Currently, some of them are not available, and I was wondering if there's a specific reason for that. If so, I would be happy to help add more options!

Usage:

$map = (new Map());

$googleOptions = (new GoogleOptions())->maxZoom(14);

$map->options($googleOptions);

@nina-alin nina-alin requested a review from Kocal as a code owner January 22, 2025 15:05
@carsonbot carsonbot added Status: Needs Review Needs to be reviewed Feature New Feature Map labels Jan 22, 2025
Copy link

github-actions bot commented Jan 22, 2025

📊 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 (Bridge Google)
map_controller.d.ts 2.55 kB / 794 B 2.57 kB0% / 797 B0%

Copy link
Member

@Kocal Kocal left a comment

Choose a reason for hiding this comment

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

Hi, thanks and congrats for your first contribution to Symfony 🎉😄

If we add (we will) support maxZoom configuration, it would be great to have support for minZoom configuration too, it should be quite simple.

Also, since this new feature is pretty generic, it would be great to add support for minZoom and maxZoom for Leaflet too. 🙏🏻

Finally, since we can configure initial, minimum, and maximum zoom values, I believe it would be nice to validate them, e.g. you don't want the initial zoom to be lower than minZoom, you don't want the minZoom to be higher that maxZoom, etc...

Feel free to reach us if needed, thanks!

@@ -1,5 +1,9 @@
# CHANGELOG

## Unreleased
Copy link
Member

Choose a reason for hiding this comment

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

We know that the next version will be 2.23, so let's add it :)

Suggested change
## Unreleased
## 2.23

@@ -1,5 +1,9 @@
# CHANGELOG

## Unreleased

- Add support for the maxZoom option
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- Add support for the maxZoom option
- Add support for the `maxZoom` option

@Kocal
Copy link
Member

Kocal commented Jan 22, 2025

I'm also unsure if you're planning to add more GoogleOptions in the future. Currently, some of them are not available, and I was wondering if there's a specific reason for that. If so, I would be happy to help add more options!

It wasn't planned, but we're totally open to adding other options :) Initially when creating UX Map and bridges, we implemented a few of the “most popular” options.

@nina-alin
Copy link
Author

Hi @Kocal,
Sorry for the delayed response.

Thank you for your awesome review! I'll take care of your comments. However, I have a few questions:

Regarding the support for minZoom and maxZoom in Leaflet, I see that it’s already covered here. Or am I missing something?

As for the validation, I’m not 100% sure how you want me to implement it. I have a few ideas, but I’m uncertain about the best approach. Could you please guide me?

@Kocal
Copy link
Member

Kocal commented Jan 31, 2025

Hey @nina-alin,
No worries about that :)

Regarding the support for minZoom and maxZoom in Leaflet, I see that it’s already covered here. Or am I missing something?

You're 100% right, I forgot that it was already supported through L.TileLayer options, that L.Map will re-use if necessary... 😅

As for the validation, I’m not 100% sure how you want me to implement it. I have a few ideas, but I’m uncertain about the best approach. Could you please guide me?

Sure! But first, I think minZoom and maxZoom must be configured at the Map level, like we do for zoom option. Those options are super generic, and I don't think there is no real need to configure them on GoogleOptions.

Then, the validation will take place in the Map class. Like we did in the Point class, we will manually assert that values are correct, and throw an Symfony\UX\Map\Exception\InvalidArgumentException if necessary.
In Map, it should be done at various place:

  • the constructor, because 2 new properties minZoom and maxZoom will be added
  • zoom(), minZoom(), maxZoom() methods
  • and toArray() for a final validation

We can introduce a new private method like assertZooms(), that will check if zoom, minZoom and maxZoom are coherent. Of course, we must ensure those values are not null before comparing them. Something like:

  • if minZoom is not null and zoom is not null and minZoom > zoom: throw exception
  • if maxZoom is not null and zoom is not null and maxZoom < zoom: throw exception
  • if minZoom is not null and maxZoom is not null and minZoom > maxZoom: throw exception
  • ...

And of course, some tests! :D

Do not hesitate to let me know if anything is unclear here.


PS: were you at the ForumPHP 2024 at DisneyLand Paris? Your face looks familiar!

@Kocal Kocal added Status: Needs Work Additional work is needed and removed Status: Needs Review Needs to be reviewed labels Feb 3, 2025
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 Work Additional work is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants