-
-
Notifications
You must be signed in to change notification settings - Fork 356
[Map] Create Map component #1937
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
Conversation
4fd1a57
to
1fb9b9b
Compare
Very useful component :) |
c97965e
to
f73bf19
Compare
src/Map/src/AssetMapper/ImportMap/Resolver/LeafletPackageResolver.php
Outdated
Show resolved
Hide resolved
That's awesome ! Thank you for this PR ! I checked my projects with Google Maps integration, there is some features missing here :
|
Hi @simondaigre, and thank you! :)
It's already on my list! I will need this feature aswell for my website where I use custom marker icons: But I don't wanted to do too much things in a single PR. Implementing
I've started to implement the API/configuration for map styles (with some classes and enums), but I've finally removed it when I knew about Cloud-based maps styling.
I think we would not include it in Symfony UX Map by default, a documentation would be enough IMO :) |
(i will make a big review this week-end ;) ) |
A first comment before touching the real work :) It is not possible to use Google Map without explicit consent of the user in Europe, California i think, Japan maybe, Australia too You are of course not responsible of this, but i think some use case or implementation consequences should be discussed now
|
... 😮💨 , but yeah you're right, thanks for pointing it out. I think the easiest way to do that is to:
For example with the Didomi CMP: <script>
window.didomiOnReady = window.didomiOnReady || [];
window.didomiOnReady.push(() => {
function loadGoogleMapsIfConsentGiven() {
const googleMapsPurposeId = '...';
const googleMapsVendorId = '...';
const userStatus = Didomi.getUserStatus();
const enabledPurposeConsent = userStatus.purposes.consent.enabled;
const enabledVendorConsent = userStatus.vendors.consent.enabled;
if (enabledPurposeConsent.includes(googleMapsPurposeId) && enabledVendorConsent.includes(googleMapsVendorId)) {
window.loadSymfonyUxGoogleMaps();
}
}
if (Didomi.shouldConsentBeCollected()) {
window.didomiEventListeners = window.didomiEventListeners || [];
window.didomiEventListeners.push({
event: 'consent.changed',
listener: function (event) {
loadGoogleMapsIfConsentGiven();
}
});
} else {
loadGoogleMapsIfConsentGiven();
}
});
</script> WDYT? |
09be8b1
to
212e61d
Compare
It's merged now! 🎉🎉🎉 Hugo, infinite thanks for contributing this amazing new component 🙇🙇🙇 and thank you all for the nice discussion and review that you did here. Now, let's test it in real apps, let's iterate on it and let's add good docs for the community. Thanks! |
Thanks @javiereguiluz :) But we still need to set-up git repositories for UX Map bridges (Google and Leaflet), AFAIK only Fabien can do that..? Do you think we can get in touch with him? 🙏 Thanks! |
@Kocal Can you list what needs to be done? Based on that, I will do the magic ;) |
So quick! :D We will need dedicated repositories for:
So packages And like other Symfony components, bridges source code should not be present in Thanks :) |
@@ -0,0 +1,33 @@ | |||
{ | |||
"name": "symfony/ux-map-google", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be symfony/ux-google-map
to be consistent with how we are naming bridges in Symfony.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm working on it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #2031
@@ -0,0 +1,33 @@ | |||
{ | |||
"name": "symfony/ux-map-leaflet", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be symfony/ux-leaflet-map
to be consistent with how we are naming bridges in Symfony.
…Kocal) This PR was merged into the 2.x branch. Discussion ---------- [Map] Rename "symfony/ux-map-%s" to "symfony/ux-%s-map" | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no <!-- 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 <!-- Replace this notice by a description of your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - For new features, provide some code snippets to help understand usage. - Features and deprecations must be submitted against branch main. - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> Following #1937 (review). Commits ------- 8e10049 [Map] Rename "symfony/ux-map-%s" to "symfony/ux-%s-map"
@Kocal All done. Can you double-check that everything has been configured properly? |
@fabpot thanks! |
Cannot wait to play with it! What an incredible PR this was, thank you very much for your patience, hard work and positive spirit @Kocal! 👏 |
Good catch, I used |
We can move folders around in the ux mono if that can ease things. |
All good now 🤞 |
This PR was merged into the 2.x branch. Discussion ---------- [Map][Leaflet] Fix Marker inside-circle | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no <!-- 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 <!-- Replace this notice by a description of your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - For new features, provide some code snippets to help understand usage. - Features and deprecations must be submitted against branch main. - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> With Leaflet, the original marker's icon (that you can find at https://www.jsdelivr.com/package/npm/leaflet?tab=files&path=dist%2Fimages), has a white circle in it, [see example](https://leafletjs.com/index.html): <img width="908" alt="Capture d’écran 2024-08-08 à 14 44 03" src="https://github.com/user-attachments/assets/21afcff7-6c23-40e8-865b-2f54700830b0"> In #1937, in my first iteration I've added Leaflet icons to Symfony AssetMapper/ImportMap but this was toooo much work. So, with Simon, we have agreed to use an inlined SVG instead, I've used the one from https://www.jsdelivr.com/package/npm/leaflet?tab=files&path=src%2Fimages, but it looks like the circle is transparent instead of white: <img width="588" alt="Capture d’écran 2024-08-08 à 14 39 05" src="https://github.com/user-attachments/assets/eea48349-57c4-4caf-b25d-7793c6b282f1"> With this PR: <img width="570" alt="Capture d’écran 2024-08-08 à 14 44 37" src="https://github.com/user-attachments/assets/3832aca7-7bb4-45c7-a0e4-1c58c7a8da0c"> Commits ------- 06e144b [Map][Leaflet] Fix Marker inside circle
Thanks Fabien :) |
…ter if fit bounds to markers (Kocal) This PR was merged into the 2.x branch. Discussion ---------- [Map] Add the possibility to not configure map zoom/center if fit bounds to markers | 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 <!-- Replace this notice by a description of your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - For new features, provide some code snippets to help understand usage. - Features and deprecations must be submitted against branch main. - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> Following a review from `@smnandre` in #1937 or in our Slack DMs. Forcing the developper to explicitly configure the center/zoom of the map does not make sense if `fitBoundsToMarker` feature is enabled. Also, I prefer throw exceptions instead of automatically enable `fitBoundsToMarker` if there are markers and center/zoom are not configured, it's more explicit like that and it mimic the Leaflet/GoogleMaps behaviors (the map can't be rendered if no center/zoom, and `fitBoundsToMarker` is a UX Map's feature). Commits ------- b3e6412 [Map] Add the possibility to not configure map zoom/center if fit bounds to markers
…kage.json` resolving (Kocal) This PR was merged into the 2.x branch. Discussion ---------- [Map] Re-add keyword "symfony-ux", to fix Symfony Flex `package.json` resolving | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no <!-- 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 <!-- Replace this notice by a description of your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - For new features, provide some code snippets to help understand usage. - Features and deprecations must be submitted against branch main. - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> In #1937 I was asked to remove the keyword `symfony-ux` in favor `symfony` and `ux`, but it looks like it break Symfony Flex behaviour to resolve the package's `package.json`: https://github.com/symfony/flex/blob/2.x/src/PackageJsonSynchronizer.php#L372 No `importmap.php` nor `assets/controllers.json` were updated when installing UX Map bridges :( I'm adding back this keyword and removing the other ones. Sorry for the inconvenience 🙏 Commits ------- e417b4b [Map] Re-add keyword "symfony-ux", to fix Symfony Flex behaviour (importmap, controllers...)
Hi :)
This PR is a proposal for #38 a replacement for #39.
Symfony UX Map is a new Symfony UX component that makes it easy to create, customize and use interactive JavaScript maps.
The package ships with:
Example
Bridge configuration
Map creation
An example to render a map, custom center and zoom, some markers and info windows:
Map rendering
You must call
render_map(map)
to render the map:It gives you this interactive Leaflet map: