symfony/ux-map
Symfony UX Map adds interactive maps to Symfony apps with easy integration for providers like Leaflet and Google Maps. Part of the Symfony UX ecosystem; documentation and issue tracking live in the main symfony/ux repository.
render_map() Twig function, use ux_map() insteadtitle from Polygon, Polyline, Rectangle and Circle, use infoWindow insteadrawOptions from ux:map:*:before-create events, use bridgeOptions instead.Map::removeAllMarkers(), Map::removeAllPolygons(), Map::removeAllPolylines(), Map::removeAllCircles() and Map::removeAllRectangles() methodsfitBoundsToMarkers parameter to ux_map() Twig functiontitle from Polygon, Polyline, Rectangle and Circle in favor of infoWindowCluster class and ClusteringAlgorithmInterface with two implementations GridClusteringAlgorithm and MortonClusteringAlgorithmminZoom and maxZoom options to Map to set the minimum and maximum zoom levelsThe fitBoundsToMarkers option is not overridden anymore when using the Map LiveComponent, but now respects the value you defined.
You may encounter unwanted behavior when adding/removing elements to the map.
To use the previous behavior, you must call $this->getMap()->fitBoundsToMarkers(false) in your LiveComponent's live actions
Add support for creating Circle by passing a Point and a radius (in meters) to the Circle constructor, e.g.:
$map->addCircle(new Circle(
center: new Point(48.856613, 2.352222), // Paris
radius: 5_000 // 5km
));
Rectangle by passing two Point instances to the Rectangle constructor, e.g.:$map->addRectangle(new Rectangle(
southWest: new Point(48.856613, 2.352222), // Paris
northEast: new Point(48.51238 2.21080) // Gare de Lyon (Paris)
));
rawOptions from ux:map:*:before-create events, in favor of bridgeOptions instead.ux:map:pre-connect event:this.element.addEventListener('ux:map:pre-connect', (event) => {
// Override the map center and zoom
event.detail.zoom = 10;
event.detail.center = { lat: 48.856613, lng: 2.352222 };
// Override the normalized `*Options` PHP classes (e.g. `GoogleMapOptions` or `LeafletMapOptions`)
console.log(event.detail.options);
// Override the options specific to the renderer bridge (e.g. `google.maps.MapOptions` or `L.MapOptions`)
event.detail.bridgeOptions = {
// ...
};
});
extra data support to Map, which can be accessed in ux:map:pre-connect and ux:map:connect eventsPolygon with holes, by passing an array of array<Point> as points parameter to the Polygon constructor, e.g.:// Draw a polygon with a hole in it, on the French map
$map->addPolygon(new Polygon(points: [
// First path, the outer boundary of the polygon
[
new Point(48.117266, -1.677792), // Rennes
new Point(50.629250, 3.057256), // Lille
new Point(48.573405, 7.752111), // Strasbourg
new Point(43.296482, 5.369780), // Marseille
new Point(44.837789, -0.579180), // Bordeaux
],
// Second path, it will make a hole in the previous one
[
new Point(45.833619, 1.261105), // Limoges
new Point(45.764043, 4.835659), // Lyon
new Point(49.258329, 4.031696), // Reims
new Point(48.856613, 2.352222), // Paris
],
]));
[@symfony](https://github.com/symfony)/ux-map dependency to the package.json file anymore.Icon to customize a Marker icon (URL or SVG content)id to Marker, Polygon and Polyline constructorsMap::removeMarker(string|Marker $markerOrId)Map::removePolygon(string|Polygon $polygonOrId)Map::removePolyline(string|Polyline $polylineOrId)DistanceUnit to represent distance units (m, km, miles, nmi) and
ease conversion between units.DistanceCalculatorInterface interface and three implementations:
HaversineDistanceCalculator, SphericalCosineDistanceCalculator and VincentyDistanceCalculator.CoordinateUtils helper, to convert decimal coordinates (43.2109) in DMS (56° 78' 90")Symfony\UX\Map\Renderer\AbstractRenderer::tapOptions(), to allow Renderer to modify options before rendering a Map.ux_map.google_maps.default_map_id configuration to set the Google Map IDComponentWithMapTrait to ease maps integration in Live ComponentsPolyline supportrender_map Twig function (will be removed in 2.21). Use
ux_map or the <twig:ux:map /> Twig component instead.ux_map Twig function (replaces render_map with a more flexible
interface)<twig:ux:map /> Twig component[@symfony](https://github.com/symfony)/ux-map/abstract-map-controller can be removed
from your importmap, it is no longer needed.Polygon supportHow can I help you explore Laravel packages today?