-
-
Notifications
You must be signed in to change notification settings - Fork 487
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
[Symfony UX Map] Create recipes for the package and its bridges #1329
Conversation
Thanks for the PR 😍 How to test these changes in your application
Diff between recipe versionsIn order to help with the review stage, I'm in charge of computing the diff between the various versions of patched recipes. |
e3712c9
to
0fb2ec6
Compare
I try it on a php8.3 / Synfony 6.4
|
Yes, the PR is still being reviewed, the packages do not exist yet |
This PR was squashed before being merged into the 2.x branch. Discussion ---------- [Map] Create Map component | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes <!-- please update src/**/CHANGELOG.md files --> | Issues | Fix #38 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT 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: - a simple and generic way to create a map, with markers and info-windows - two Bridge, [Leaflet](https://leafletjs.com/index.html) and [Google Maps](https://developers.google.com/maps/documentation/javascript) - a way to define provider-specific options - a nice and fluent API - Flex recipes are also ready: symfony/recipes#1329 # Example ## Bridge configuration ```env # .env UX_MAP_DSN=leaflet://default ``` ```yaml # config/packages/ux_map.yaml ux_map: renderer: '%env(UX_MAP_DSN)%' ``` ## Map creation An example to render a map, custom center and zoom, some markers and info windows: ```php namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\UX\Map\InfoWindow; use Symfony\UX\Map\MapFactoryInterface; use Symfony\UX\Map\Marker; use Symfony\UX\Map\Point; final class ContactController extends AbstractController { #[Route('/contact')] public function __invoke(): Response { // 1. Create a new map instance $myMap = (new Map()); ->center(new Point(46.903354, 1.888334)) ->zoom(6) ; // 2. You can add markers, with an optional info window $myMap ->addMarker(new Marker( position: new Point(48.8566, 2.3522), title: 'Paris' )) ->addMarker(new Marker( position: new Point(45.7640, 4.8357), title: 'Lyon', // With an info window infoWindow: new InfoWindow( headerContent: '<b>Lyon</b>', content: 'The French town in the historic Rhône-Alpes region, located at the junction of the Rhône and Saône rivers.' ) )); // 3. And inject the map in your template to render it return $this->render('contact/index.html.twig', [ 'my_map' => $myMap, ]); } } ``` ## Map rendering You must call `render_map(map)` to render the map: ```twig {{ render_map(map, { style: 'height: 700px; width: 1024px; margin: 10px' }) }} ``` It gives you this interactive Leaflet map: <img width="1524" alt="image" src="https://github.com/user-attachments/assets/cd0f64f3-5bf2-45c6-8b8d-8ad23c6ce183"> Commits ------- 212e61d [Map] Create Map component
@Kocal Not a draft anymore, right? |
@fabpot it should be alright now |
We now need a 2.19 version of UX. Can I make the releases? |
@kbond maybe? |
@fabpot, can we do it Friday? |
Sure, no problems. Just ping me when you're ready. |
Head branch was pushed to by a user without write access
38226dd
to
cb80c70
Compare
Head branch was pushed to by a user without write access
cb80c70
to
930ad77
Compare
Head branch was pushed to by a user without write access
930ad77
to
8cc172a
Compare
Head branch was pushed to by a user without write access
8cc172a
to
37f852e
Compare
Adding recipies for the new Symfony UX Map package and its Bridges, currently being reviewed in symfony/ux#1937.
I've specified version 2.19, but it may be 2.20 instead, let's keep it in draft then.