/ux-map
Symfony UX Map for interactive maps with Leaflet or Google Maps in Symfony. Covers markers, polygons, polylines, circles, info windows, and LiveComponent integration. Use when displaying maps, placing markers, drawing shapes or routes, handling map events, building store
$ npx -y skills add smnandre/symfony-ux-skills --skill ux-map --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.
- You can call itInvoke it directly when you want it.
- Slash command
/ux-map
Context preview
The summary Claude sees to decide when to auto-load this skill.
Symfony UX Map for interactive maps with Leaflet or Google Maps in Symfony. Covers markers, polygons, polylines, circles, info windows, and LiveComponent integration. Use when displaying maps, placing markers, drawing shapes or routes, handling map events, building store
SKILL.md
ux-map.SKILL.mdname: ux-map
description: 'Symfony UX Map for interactive maps with Leaflet or Google Maps in Symfony. Covers markers, polygons, polylines, circles, info windows, and LiveComponent integration. Use when displaying maps, placing markers, drawing shapes or routes, handling map events, building store locators, using custom tile layers, or making maps reactive with LiveComponent. Code triggers: <twig:ux:map />, Map(), Point(), Marker(), Polygon(), Polyline(), Circle(), InfoWindow(), MapOptionsInterface, ComponentWithMapTrait, fitBoundsToMarkers, ux:map:marker:before-create, ux:map:connect, SYMFONY_UX_MAP_DSN. Also trigger when the user asks "how to display a map", "how to add markers", "how to draw a polygon on a map", "how to handle map click events", "how to make a reactive map", "how to use Leaflet in Symfony", "how to use Google Maps in Symfony", "map not showing", "map has zero height". Do NOT trigger for SVG icons (use ux-icons) or general frontend interactivity (use stimulus).'
license: MIT
metadata:
author: Simon Andre
email: smn.andre@gmail.com
url: https://smnandre.dev
version: "1.2.0"
UX Map
Interactive maps in Symfony with Leaflet or Google Maps. Build maps in PHP, render them in Twig, and extend them with Stimulus controllers. Supports markers, polygons, polylines, circles, info windows, and LiveComponent integration.
Installation
# Install the base package
composer require symfony/ux-map
# Then install ONE renderer:
composer require symfony/ux-leaflet-map # Leaflet (free, open source)
# OR
composer require symfony/ux-google-map # Google Maps (requires API key)
Quick Reference
Map PHP object, holds markers/shapes/options
Point latitude + longitude
Marker pin on the map, optional InfoWindow
Polygon closed shape (array of Points)
Polyline open line (array of Points)
Circle center Point + radius in meters
InfoWindow popup attached to a Marker, Polygon, or Circle
ux_map(map, attrs) Twig function to render a Map
<twig:ux:map /> Twig component (requires ux-twig-component)
Building a Map in PHP
use Symfony\UX\Map\Map;
use Symfony\UX\Map\Point;
use Symfony\UX\Map\Marker;
use Symfony\UX\Map\InfoWindow;
use Symfony\UX\Map\Polygon;
use Symfony\UX\Map\Polyline;
use Symfony\UX\Map\Circle;
$map = (new Map())
->center(new Point(48.8566, 2.3522))
->zoom(12)
->minZoom(3)
->maxZoom(18);
// Marker with info window
$map->addMarker(new Marker(
position: new Point(48.8566, 2.3522),
title: 'Paris',
infoWindow: new InfoWindow(
headerContent: '<b>Paris</b>',
content: 'The capital of France',
),
));
// Marker with custom icon (UX Icons integration)
$map->addMarker(new Marker(
position: new Point(48.8738, 2.2950),
title: 'Eiffel Tower',
icon: Icon::ux('mdi:tower-eiffel')->width(32)->height(32),
extra: ['category' => 'landmark'],
));
// Polygon (closed area)
$map->addPolygon(new Polygon(
points: [
new Point(48.8566, 2.3522),
new Point(48.8606, 2.3376),
new Point(48.8530, 2.3499),
],
infoWindow: new InfoWindow(content: 'Central Paris area'),
));
// Polyline (open line)
$map->addPolyline(new Polyline(
points: [
new Point(48.8566, 2.3522),
new Point(48.8738, 2.2950),
],
));
// Circle (center + radius in meters)
$map->addCircle(new Circle(
center: new Point(48.8566, 2.3522),
radius: 500,
infoWindow: new InfoWindow(content: '500m radius'),
));
// Auto-fit bounds to show all markers
$map->fitBoundsToMarkers();Rendering in Twig
Twig Function
{# Basic rendering #}
{{ ux_map(map, {style: 'height: 400px; width: 100%;'}) }}
{# With custom attributes and Stimulus controller #}
{{ ux_map(map, {
'data-controller': 'custom-map',
style: 'height: 400px;',
class: 'rounded shadow'
}) }}Twig Component (HTML Syntax)
Requires `symfony/ux-twig-component`. Allows inline map definition without PHP:
<twig:ux:map
:center="[48.8566, 2.3522]"
zoom="12"
:markers='[
{"position": [48.8566, 2.3522], "title": "Paris"},
{"position": [48.8738, 2.2950], "title": "Eiffel Tower",
"infoWindow": {"content": "324m tall"}}
]'
:fitBoundsToMarkers="true"
style="height: 400px; width: 100%;"
class="rounded shadow"
/>Configuration
# config/packages/ux_map.yaml
ux_map:
renderer: '%env(resolve:default::UX_MAP_DSN)%'
# Google Maps specific
google_maps:
default_map_id: null # Optional: default Map ID for all mapsRenderer DSN
Set in `.env`:
# Leaflet (free)
UX_MAP_DSN=leaflet://default
# Google Maps (requires API key)
UX_MAP_DSN=google://GOOGLE_MAPS_API_KEY@default
Renderer Options
Leaflet Options
use Symfony\UX\Map\Bridge\Leaflet\LeafletOptions;
use Symfony\UX\Map\Bridge\Leaflet\Option\TileLayer;
use Symfony\UX\Map\Bridge\Leaflet\Option\ZoomControlOptions;
use Symfony\UX\Map\Bridge\Leaflet\Option\AttributionControlOptions;
use Symfony\UX\Map\Bridge\Leaflet\Option\ControlPosition;
$leafletOptions = (new LeafletOptions())
->tileLayer(new TileLayer(
url: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
attribution: '© OpenStreetMap contributors',
options: ['minZoom' => 5, 'maxZoom' => 18],
))
->zoomControl(true)
->zoomControlOptions(new ZoomControlOptions(ControlPosition::TOP_LEFT))
->attributionControl(true)
->attributionControlOptions(new AttributionControlOptions(ControlPosition::BOTTOM_LEFT));
$map->options($leafletOptions);Google Maps Options
use Symfony\UX\Map\Bridge\Google\GoogleOptions;
use Symfony\UX\Map\Bridge\Google\Option\ControlPosition;
use Symfony\UX\Map\Bridge\Google\Option\GestureHandling;
use Symfony\UX\Map\Bridge\Google\Option\MapTypeControlOptions;
use
Read more
name: ux-map description: 'Symfony UX Map for interactive maps with Leaflet or Google Maps in Symfony. Covers markers, polygons, polylines, circles, info windows, and LiveComponent integration. Use when displaying maps, placing markers, drawing shapes or routes, handling map events, building store locators, using custom tile layers, or making maps reactive with LiveComponent. Code triggers: <twig:ux:map />, Map(), Point(), Marker(), Polygon(), Polyline(), Circle(), InfoWindow(), MapOptionsInterface, ComponentWithMapTrait, fitBoundsToMarkers, ux:map:marker:before-create, ux:map:connect, SYMFONY_UX_MAP_DSN. Also trigger when the user asks "how to display a map", "how to add markers", "how to draw a polygon on a map", "how to handle map click events", "how to make a reactive map", "how to use Leaflet in Symfony", "how to use Google Maps in Symfony", "map not showing", "map has zero height". Do NOT trigger for SVG icons (use ux-icons) or general frontend interactivity (use stimulus).' license: MIT metadata: author: Simon Andre email: smn.andre@gmail.com url: https://smnandre.dev version: "1.2.0"
UX Map
Interactive maps in Symfony with Leaflet or Google Maps. Build maps in PHP, render them in Twig, and extend them with Stimulus controllers. Supports markers, polygons, polylines, circles, info windows, and LiveComponent integration.
Installation
# Install the base package composer require symfony/ux-map # Then install ONE renderer: composer require symfony/ux-leaflet-map # Leaflet (free, open source) # OR composer require symfony/ux-google-map # Google Maps (requires API key)
Quick Reference
Map PHP object, holds markers/shapes/options Point latitude + longitude Marker pin on the map, optional InfoWindow Polygon closed shape (array of Points) Polyline open line (array of Points) Circle center Point + radius in meters InfoWindow popup attached to a Marker, Polygon, or Circle ux_map(map, attrs) Twig function to render a Map <twig:ux:map /> Twig component (requires ux-twig-component)
Building a Map in PHP
use Symfony\UX\Map\Map;
use Symfony\UX\Map\Point;
use Symfony\UX\Map\Marker;
use Symfony\UX\Map\InfoWindow;
use Symfony\UX\Map\Polygon;
use Symfony\UX\Map\Polyline;
use Symfony\UX\Map\Circle;
$map = (new Map())
->center(new Point(48.8566, 2.3522))
->zoom(12)
->minZoom(3)
->maxZoom(18);
// Marker with info window
$map->addMarker(new Marker(
position: new Point(48.8566, 2.3522),
title: 'Paris',
infoWindow: new InfoWindow(
headerContent: '<b>Paris</b>',
content: 'The capital of France',
),
));
// Marker with custom icon (UX Icons integration)
$map->addMarker(new Marker(
position: new Point(48.8738, 2.2950),
title: 'Eiffel Tower',
icon: Icon::ux('mdi:tower-eiffel')->width(32)->height(32),
extra: ['category' => 'landmark'],
));
// Polygon (closed area)
$map->addPolygon(new Polygon(
points: [
new Point(48.8566, 2.3522),
new Point(48.8606, 2.3376),
new Point(48.8530, 2.3499),
],
infoWindow: new InfoWindow(content: 'Central Paris area'),
));
// Polyline (open line)
$map->addPolyline(new Polyline(
points: [
new Point(48.8566, 2.3522),
new Point(48.8738, 2.2950),
],
));
// Circle (center + radius in meters)
$map->addCircle(new Circle(
center: new Point(48.8566, 2.3522),
radius: 500,
infoWindow: new InfoWindow(content: '500m radius'),
));
// Auto-fit bounds to show all markers
$map->fitBoundsToMarkers();Rendering in Twig
Twig Function
{# Basic rendering #}
{{ ux_map(map, {style: 'height: 400px; width: 100%;'}) }}
{# With custom attributes and Stimulus controller #}
{{ ux_map(map, {
'data-controller': 'custom-map',
style: 'height: 400px;',
class: 'rounded shadow'
}) }}Twig Component (HTML Syntax)
Requires `symfony/ux-twig-component`. Allows inline map definition without PHP:
<twig:ux:map
:center="[48.8566, 2.3522]"
zoom="12"
:markers='[
{"position": [48.8566, 2.3522], "title": "Paris"},
{"position": [48.8738, 2.2950], "title": "Eiffel Tower",
"infoWindow": {"content": "324m tall"}}
]'
:fitBoundsToMarkers="true"
style="height: 400px; width: 100%;"
class="rounded shadow"
/>Configuration
# config/packages/ux_map.yaml
ux_map:
renderer: '%env(resolve:default::UX_MAP_DSN)%'
# Google Maps specific
google_maps:
default_map_id: null # Optional: default Map ID for all mapsRenderer DSN
Set in `.env`:
# Leaflet (free) UX_MAP_DSN=leaflet://default # Google Maps (requires API key) UX_MAP_DSN=google://GOOGLE_MAPS_API_KEY@default
Renderer Options
Leaflet Options
use Symfony\UX\Map\Bridge\Leaflet\LeafletOptions;
use Symfony\UX\Map\Bridge\Leaflet\Option\TileLayer;
use Symfony\UX\Map\Bridge\Leaflet\Option\ZoomControlOptions;
use Symfony\UX\Map\Bridge\Leaflet\Option\AttributionControlOptions;
use Symfony\UX\Map\Bridge\Leaflet\Option\ControlPosition;
$leafletOptions = (new LeafletOptions())
->tileLayer(new TileLayer(
url: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
attribution: '© OpenStreetMap contributors',
options: ['minZoom' => 5, 'maxZoom' => 18],
))
->zoomControl(true)
->zoomControlOptions(new ZoomControlOptions(ControlPosition::TOP_LEFT))
->attributionControl(true)
->attributionControlOptions(new AttributionControlOptions(ControlPosition::BOTTOM_LEFT));
$map->options($leafletOptions);Google Maps Options
use Symfony\UX\Map\Bridge\Google\GoogleOptions; use Symfony\UX\Map\Bridge\Google\Option\ControlPosition; use Symfony\UX\Map\Bridge\Google\Option\GestureHandling; use Symfony\UX\Map\Bridge\Google\Option\MapTypeControlOptions; use
Showing the first part of this file.
AI agent skills for the Symfony UX frontend stack -- Stimulus, Turbo, TwigComponent, LiveComponent, UX Icons and UX Map. By Simon Andre
Repo: smnandre/symfony-ux-skills
Other skills on symfony-ux-skills.
- /live-component
Symfony UX LiveComponent for reactive server-rendered UI -- components that re-render via AJAX on user interaction, zero JavaScript required. Use when building live search, real-time filtering, dynamic forms, inline validation, dependent selects, auto-save, polling,
Open skill - /stimulus
Stimulus JS framework for Symfony UX -- client-side behavior via HTML data attributes, zero server round-trips. Use when creating controllers for DOM manipulation, handling click/input/submit events, managing targets and values, wiring outlets between controllers, wrapping
Open skill - /symfony-ux
Symfony UX frontend stack -- decision tree and orchestrator for choosing between Stimulus, Turbo, TwigComponent, LiveComponent, UX Icons, and UX Map. Use when the user is unsure which tool fits, wants to combine multiple UX packages, or asks a general frontend architecture
Open skill - /turbo
Hotwire Turbo for Symfony UX -- SPA-like speed with zero JavaScript. Covers Drive (navigation), Frames (partial page sections), and Streams (multi-target updates). Use when building ajax navigation, lazy-loaded sections, inline editing, pagination without reload, modals from the
Open skill - /twig-component
Symfony UX TwigComponent for reusable UI building blocks -- server-rendered components with PHP classes and Twig templates. Use when creating buttons, cards, alerts, badges, navbars, or any reusable UI element with props, blocks/slots, computed properties, or anonymous
Open skill - /ux-icons
Symfony UX Icons for rendering SVG icons in Twig templates. Supports 200,000+ Iconify icons (Lucide, Heroicons, Tabler, Material Design, etc.), local SVG files, and custom icon sets with aliases. Use when displaying icons, configuring icon defaults, importing or locking
Open skill

