Skip to content

Commit ad52699

Browse files
committed
allow marker, polygone and polyline removal
1 parent feb0256 commit ad52699

19 files changed

+402
-59
lines changed

src/Icons/config/twig_component.php

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
1313

1414
use Symfony\UX\Icons\Twig\UXIconComponent;
15-
use Symfony\UX\Icons\Twig\UXIconComponentListener;
1615

1716
return static function (ContainerConfigurator $container): void {
1817
$container->services()

src/LiveComponent/tests/Functional/EventListener/LiveComponentSubscriberTest.php

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
namespace Symfony\UX\LiveComponent\Tests\Functional\EventListener;
1313

1414
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
15-
use Symfony\Component\DomCrawler\Crawler;
16-
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
1715
use Symfony\Component\Security\Core\User\InMemoryUser;
1816
use Symfony\Component\Security\Http\Attribute\IsGranted;
1917
use Symfony\UX\LiveComponent\Tests\Fixtures\Entity\Entity1;

src/LiveComponent/tests/Integration/EventListener/DataModelPropsSubscriberTest.php

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\UX\LiveComponent\Tests\Integration\EventListener;
1313

1414
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
15-
use Symfony\Component\HttpFoundation\Request;
1615
use Symfony\UX\LiveComponent\Tests\LiveComponentTestHelper;
1716
use Symfony\UX\TwigComponent\ComponentRenderer;
1817

src/LiveComponent/tests/Integration/LiveComponentHydratorTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ public function mount()
978978

979979
return HydrationTest::create(new class {
980980
/**
981-
* @var \Symfony\UX\LiveComponent\Tests\Fixtures\Dto\Address[]
981+
* @var Address[]
982982
*/
983983
#[LiveProp(writable: true, useSerializerForHydration: true)]
984984
public array $addresses = [];
@@ -1009,7 +1009,7 @@ public function mount()
10091009

10101010
return HydrationTest::create(new class {
10111011
/**
1012-
* @var \Symfony\UX\LiveComponent\Tests\Fixtures\Dto\Address[]
1012+
* @var Address[]
10131013
*/
10141014
#[LiveProp(writable: true, useSerializerForHydration: true)]
10151015
public array $addresses = [];
@@ -1037,7 +1037,7 @@ public function mount()
10371037
yield 'Array with DTOs: fully writable allows deep partial changes' => [function () {
10381038
return HydrationTest::create(new class {
10391039
/**
1040-
* @var \Symfony\UX\LiveComponent\Tests\Fixtures\Dto\HoldsArrayOfDtos[] $dtos
1040+
* @var HoldsArrayOfDtos[] $dtos
10411041
*/
10421042
#[LiveProp(writable: true, useSerializerForHydration: true)]
10431043
public array $dtos = [];
@@ -1157,7 +1157,7 @@ public function mount()
11571157

11581158
yield 'Collection: using serializer (de)hydrates correctly' => [function () {
11591159
return HydrationTest::create(new class {
1160-
/** @var \Symfony\UX\LiveComponent\Tests\Fixtures\Dto\Temperature[] */
1160+
/** @var Temperature[] */
11611161
#[LiveProp(useSerializerForHydration: true)]
11621162
public array $temperatures = [];
11631163

src/Map/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
`HaversineDistanceCalculator`, `SphericalCosineDistanceCalculator` and `VincentyDistanceCalculator`.
99
- Add `CoordinateUtils` helper, to convert decimal coordinates (`43.2109`) in DMS (`56° 78' 90"`)
1010

11+
- Add property `$id` to Marker`, `Polygon` and `Polyline` constructors
12+
- Add method `Symfony\UX\Map::removeMarker(string|Marker $markerOrId)`, to allow removal of a marker from its identifier
13+
- Add method `Symfony\UX\Map::removePolygon(string|Polygon $markerOrId)`, to allow removal of a polygon from its identifier
14+
- Add method `Symfony\UX\Map::removePolyline(string|Polyline $markerOrId)`, to allow removal of a polyline from its identifier
15+
1116
## 2.22
1217

1318
- Add method `Symfony\UX\Map\Renderer\AbstractRenderer::tapOptions()`, to allow Renderer to modify options before rendering a Map.

src/Map/doc/index.rst

+29-2
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,37 @@ You can add markers to a map using the ``addMarker()`` method::
136136
))
137137
;
138138

139+
Remove elements from Map
140+
~~~~~~~~~~~~~~~~~~~~~~~~
141+
142+
It is possible to remove elements like ``Marker``, ``Polygon`` and ``Polyline`` instances by using methods ``Map::remove*()``:
143+
// Add elements
144+
$map->addMarker($marker = new Marker(/* ... */));
145+
$map->addPolygon($polygon = new Polygon(/* ... */));
146+
$map->addPolyline($polyline = new Polyline(/* ... */));
147+
148+
// And later, remove those elements
149+
$map->removeMarker($marker);
150+
$map->removePolygon($polygon);
151+
$map->removePolyline($polyline);
152+
153+
If unfortunately you were unable to store an element instance, you can still remove them by passing the identifier string:
154+
155+
$map = new Map(/* ... */);
156+
// Add elements
157+
$map->addMarker(new Marker(id: 'my-marker', /* ... */));
158+
$map->addPolygon(new Polygon(id: 'my-polygon', /* ... */));
159+
$map->addPolyline(new Polyline(id: 'my-marker', /* ... */));
160+
161+
// And later, remove those elements
162+
$map->removeMarker('my-marker');
163+
$map->removePolygon('my-polygon');
164+
$map->removePolyline('my-marker');
165+
139166
Add Polygons
140167
~~~~~~~~~~~~
141168

142-
You can also add Polygons, which represents an area enclosed by a series of ``Point`` instances::
169+
You can also add Polygons, which represents an area enclosed by a series of ``Point`` instances:
143170

144171
$myMap->addPolygon(new Polygon(
145172
points: [
@@ -156,7 +183,7 @@ You can also add Polygons, which represents an area enclosed by a series of ``Po
156183
Add Polylines
157184
~~~~~~~~~~~~~
158185

159-
You can add Polylines, which represents a path made by a series of ``Point`` instances::
186+
You can add Polylines, which represents a path made by a series of ``Point`` instances:
160187

161188
$myMap->addPolyline(new Polyline(
162189
points: [

0 commit comments

Comments
 (0)