Interactive Maps
Add Map to your app.
Render interactive Maps in PHP with Leaflet or Google Maps.
// ... use statements hidden - click to show
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>',
)
));
return $this->render('ux_packages/map.html.twig', [
'map' => $map,
]);
}
}
{% extends 'base.html.twig' %}
{% block body %}
<div>
{# The map must have a defined height #}
{{ ux_map(map, {style: 'height: 600px;'}) }}
</div>
{% endblock %}
UX Map