-
-
Notifications
You must be signed in to change notification settings - Fork 345
/
Copy pathMapController.php
53 lines (46 loc) · 1.63 KB
/
MapController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Controller\UxPackage;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\UX\Map\Bridge\Leaflet\LeafletOptions;
use Symfony\UX\Map\Bridge\Leaflet\Option\TileLayer;
use Symfony\UX\Map\InfoWindow;
use Symfony\UX\Map\Map;
use Symfony\UX\Map\Marker;
use Symfony\UX\Map\Point;
class MapController extends AbstractController
{
#[Route('/map', name: 'app_map')]
public function __invoke(): Response
{
$map = (new Map('default'))
->center(new Point(45.7534031, 4.8295061))
->zoom(6)
->addMarker(new Marker(
position: new Point(45.7534031, 4.8295061),
title: 'Lyon',
infoWindow: new InfoWindow(
content: '<p>Thank you <a href="https://github.com/Kocal">@Kocal</a> for this component!</p>',
)
))
->options((new LeafletOptions())
->tileLayer(new TileLayer(
url: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',
options: ['maxZoom' => 19]
))
);
return $this->render('ux_packages/map.html.twig', [
'map' => $map,
]);
}
}