Open Kocal opened 1 week ago
Very useful component :)
That's awesome ! Thank you for this PR ! I checked my projects with Google Maps integration, there is some features missing here :
@googlemaps/markerclusterer
. Not sure if you should include it in ux/maps but I'll do a doc PR with explanations if you wantHi @simondaigre, and thank you! :)
allow to set a custom icon on Marker
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 PinElement
PHP-side is a small challenge which I think can already be done user-side with event listeners.
allow to customize map styles (styles parameter as array ?)
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.
You can pass the mapId
or call ->setMapId('...')
to customize your map styles.
on some projects I also use
@googlemaps/markerclusterer
. Not sure if you should include it in ux/maps but I'll do a doc PR with explanations if you want
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:
render_map(...)
, we won't render data-controller
attribute but something else (e.g.: data-controller-wait-for-consent
or something more related to Symfony UX Map), so the GoogleMaps Stimulus controller & Google Maps API won't be loadedloadSymfonyUxGoogleMaps()
:
{{ ux_map_script_tags() }}
data-controller-wait-for-consent
to data-controller
, which will load the Stimulus controller & Google Maps APIloadSymfonyUxGoogleMaps()
when neededFor 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?
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.
Currently, only the Google Maps and Leaflet providers are supported.
For each provider, there is:
Here an example to render a Google Maps, with a custom MapId, custom center and zoom, some markers and info windows:
The Twig code:
It gives you this interactive Google Maps map:
I'm opening the PR this morning, and I'll try to comment on some of my choices as soon as possible before you start the review :)