[Map] Add Map::removeAll*() methods

This commit is contained in:
Steven Renaux
2025-12-21 00:00:47 +01:00
committed by Hugo Alliaume
parent 1942ff472c
commit 3fd186f668
6 changed files with 125 additions and 0 deletions

View File

@@ -74,6 +74,16 @@ class GoogleRendererTest extends RendererTestCase
->removeMarker('marker2'),
];
yield 'with all markers removed with removeAllMarkers()' => [
'renderer' => new GoogleRenderer(new StimulusHelper(null), new UxIconRenderer(null), apiKey: 'api_key'),
'map' => (new Map())
->center(new Point(48.8566, 2.3522))
->zoom(12)
->addMarker($marker1)
->addMarker($marker2)
->removeAllMarkers(),
];
yield 'with marker remove and new ones added' => [
'renderer' => new GoogleRenderer(new StimulusHelper(null), new UxIconRenderer(null), apiKey: 'api_key'),
'map' => (new Map())
@@ -94,6 +104,16 @@ class GoogleRendererTest extends RendererTestCase
->addPolygon(new Polygon(points: [new Point(1.1, 2.2), new Point(3.3, 4.4), new Point(5.5, 6.6)], infoWindow: new InfoWindow(content: 'Polygon'))),
];
yield 'with all polygons removed with removeAllPolygons()' => [
'renderer' => new GoogleRenderer(new StimulusHelper(null), new UxIconRenderer(null), apiKey: 'api_key'),
'map' => (new Map())
->center(new Point(48.8566, 2.3522))
->zoom(12)
->addPolygon(new Polygon(points: [new Point(48.8566, 2.3522), new Point(48.8566, 2.3522), new Point(48.8566, 2.3522)]))
->addPolygon(new Polygon(points: [new Point(1.1, 2.2), new Point(3.3, 4.4), new Point(5.5, 6.6)], infoWindow: new InfoWindow(content: 'Polygon')))
->removeAllPolygons(),
];
yield 'with polylines and infoWindows' => [
'renderer' => new GoogleRenderer(new StimulusHelper(null), new UxIconRenderer(null), apiKey: 'api_key'),
'map' => (new Map())
@@ -103,6 +123,16 @@ class GoogleRendererTest extends RendererTestCase
->addPolyline(new Polyline(points: [new Point(1.1, 2.2), new Point(3.3, 4.4), new Point(5.5, 6.6)], infoWindow: new InfoWindow(content: 'Polygon'))),
];
yield 'with all polylines removed with removeAllPolylines()' => [
'renderer' => new GoogleRenderer(new StimulusHelper(null), new UxIconRenderer(null), apiKey: 'api_key'),
'map' => (new Map())
->center(new Point(48.8566, 2.3522))
->zoom(12)
->addPolyline(new Polyline(points: [new Point(48.8566, 2.3522), new Point(48.8566, 2.3522), new Point(48.8566, 2.3522)]))
->addPolyline(new Polyline(points: [new Point(1.1, 2.2), new Point(3.3, 4.4), new Point(5.5, 6.6)], infoWindow: new InfoWindow(content: 'Polyline')))
->removeAllPolylines(),
];
yield 'with circles and infoWindows' => [
'renderer' => new GoogleRenderer(new StimulusHelper(null), new UxIconRenderer(null), apiKey: 'api_key'),
'map' => (new Map())
@@ -112,6 +142,16 @@ class GoogleRendererTest extends RendererTestCase
->addCircle(new Circle(center: new Point(1.1, 2.2), radius: 1000, infoWindow: new InfoWindow(content: 'Circle'))),
];
yield 'with all circles removed with removeAllCircles()' => [
'renderer' => new GoogleRenderer(new StimulusHelper(null), new UxIconRenderer(null), apiKey: 'api_key'),
'map' => (new Map())
->center(new Point(48.8566, 2.3522))
->zoom(12)
->addCircle(new Circle(center: new Point(48.8566, 2.3522), radius: 500, infoWindow: new InfoWindow(content: 'Circle')))
->addCircle(new Circle(center: new Point(1.1, 2.2), radius: 1000, infoWindow: new InfoWindow(content: 'Circle')))
->removeAllCircles(),
];
yield 'with rectangles and infoWindows' => [
'renderer' => new GoogleRenderer(new StimulusHelper(null), new UxIconRenderer(null), apiKey: 'api_key'),
'map' => (new Map())
@@ -121,6 +161,16 @@ class GoogleRendererTest extends RendererTestCase
->addRectangle(new Rectangle(southWest: new Point(1.1, 2.2), northEast: new Point(3.3, 4.4), infoWindow: new InfoWindow(content: 'Rectangle'))),
];
yield 'with all rectangles removed with removeAllRectangles()' => [
'renderer' => new GoogleRenderer(new StimulusHelper(null), new UxIconRenderer(null), apiKey: 'api_key'),
'map' => (new Map())
->center(new Point(48.8566, 2.3522))
->zoom(12)
->addRectangle(new Rectangle(southWest: new Point(48.8566, 2.3522), northEast: new Point(48.8566, 2.3522), infoWindow: new InfoWindow(content: 'Rectangle')))
->addRectangle(new Rectangle(southWest: new Point(1.1, 2.2), northEast: new Point(3.3, 4.4), infoWindow: new InfoWindow(content: 'Rectangle')))
->removeAllRectangles(),
];
yield 'with controls enabled' => [
'renderer' => new GoogleRenderer(new StimulusHelper(null), new UxIconRenderer(null), apiKey: 'api_key'),
'map' => (new Map())

View File

@@ -0,0 +1,15 @@
<!-- This HTML has been prettified for testing purposes, and may not represent the actual HTML output.
Run "php vendor/bin/phpunit -d --update-snapshots" to update the snapshot. -->
<div
data-controller="symfony--ux-google-map--map"
data-symfony--ux-google-map--map-provider-options-value="{&quot;apiKey&quot;:&quot;api_key&quot;}"
data-symfony--ux-google-map--map-center-value="{&quot;lat&quot;:48.8566,&quot;lng&quot;:2.3522}"
data-symfony--ux-google-map--map-zoom-value="12"
data-symfony--ux-google-map--map-fit-bounds-to-markers-value="false"
data-symfony--ux-google-map--map-options-value="{&quot;mapId&quot;:null,&quot;gestureHandling&quot;:&quot;auto&quot;,&quot;backgroundColor&quot;:null,&quot;disableDoubleClickZoom&quot;:false,&quot;zoomControlOptions&quot;:{&quot;position&quot;:22},&quot;mapTypeControlOptions&quot;:{&quot;mapTypeIds&quot;:[],&quot;position&quot;:14,&quot;style&quot;:0},&quot;streetViewControlOptions&quot;:{&quot;position&quot;:22},&quot;fullscreenControlOptions&quot;:{&quot;position&quot;:20},&quot;@provider&quot;:&quot;google&quot;}"
data-symfony--ux-google-map--map-markers-value="[]"
data-symfony--ux-google-map--map-polygons-value="[]"
data-symfony--ux-google-map--map-polylines-value="[]"
data-symfony--ux-google-map--map-circles-value="[]"
data-symfony--ux-google-map--map-rectangles-value="[]"
></div>

View File

@@ -0,0 +1,15 @@
<!-- This HTML has been prettified for testing purposes, and may not represent the actual HTML output.
Run "php vendor/bin/phpunit -d --update-snapshots" to update the snapshot. -->
<div
data-controller="symfony--ux-google-map--map"
data-symfony--ux-google-map--map-provider-options-value="{&quot;apiKey&quot;:&quot;api_key&quot;}"
data-symfony--ux-google-map--map-center-value="{&quot;lat&quot;:48.8566,&quot;lng&quot;:2.3522}"
data-symfony--ux-google-map--map-zoom-value="12"
data-symfony--ux-google-map--map-fit-bounds-to-markers-value="false"
data-symfony--ux-google-map--map-options-value="{&quot;mapId&quot;:null,&quot;gestureHandling&quot;:&quot;auto&quot;,&quot;backgroundColor&quot;:null,&quot;disableDoubleClickZoom&quot;:false,&quot;zoomControlOptions&quot;:{&quot;position&quot;:22},&quot;mapTypeControlOptions&quot;:{&quot;mapTypeIds&quot;:[],&quot;position&quot;:14,&quot;style&quot;:0},&quot;streetViewControlOptions&quot;:{&quot;position&quot;:22},&quot;fullscreenControlOptions&quot;:{&quot;position&quot;:20},&quot;@provider&quot;:&quot;google&quot;}"
data-symfony--ux-google-map--map-markers-value="[]"
data-symfony--ux-google-map--map-polygons-value="[]"
data-symfony--ux-google-map--map-polylines-value="[]"
data-symfony--ux-google-map--map-circles-value="[]"
data-symfony--ux-google-map--map-rectangles-value="[]"
></div>

View File

@@ -0,0 +1,15 @@
<!-- This HTML has been prettified for testing purposes, and may not represent the actual HTML output.
Run "php vendor/bin/phpunit -d --update-snapshots" to update the snapshot. -->
<div
data-controller="symfony--ux-google-map--map"
data-symfony--ux-google-map--map-provider-options-value="{&quot;apiKey&quot;:&quot;api_key&quot;}"
data-symfony--ux-google-map--map-center-value="{&quot;lat&quot;:48.8566,&quot;lng&quot;:2.3522}"
data-symfony--ux-google-map--map-zoom-value="12"
data-symfony--ux-google-map--map-fit-bounds-to-markers-value="false"
data-symfony--ux-google-map--map-options-value="{&quot;mapId&quot;:null,&quot;gestureHandling&quot;:&quot;auto&quot;,&quot;backgroundColor&quot;:null,&quot;disableDoubleClickZoom&quot;:false,&quot;zoomControlOptions&quot;:{&quot;position&quot;:22},&quot;mapTypeControlOptions&quot;:{&quot;mapTypeIds&quot;:[],&quot;position&quot;:14,&quot;style&quot;:0},&quot;streetViewControlOptions&quot;:{&quot;position&quot;:22},&quot;fullscreenControlOptions&quot;:{&quot;position&quot;:20},&quot;@provider&quot;:&quot;google&quot;}"
data-symfony--ux-google-map--map-markers-value="[]"
data-symfony--ux-google-map--map-polygons-value="[]"
data-symfony--ux-google-map--map-polylines-value="[]"
data-symfony--ux-google-map--map-circles-value="[]"
data-symfony--ux-google-map--map-rectangles-value="[]"
></div>

View File

@@ -0,0 +1,15 @@
<!-- This HTML has been prettified for testing purposes, and may not represent the actual HTML output.
Run "php vendor/bin/phpunit -d --update-snapshots" to update the snapshot. -->
<div
data-controller="symfony--ux-google-map--map"
data-symfony--ux-google-map--map-provider-options-value="{&quot;apiKey&quot;:&quot;api_key&quot;}"
data-symfony--ux-google-map--map-center-value="{&quot;lat&quot;:48.8566,&quot;lng&quot;:2.3522}"
data-symfony--ux-google-map--map-zoom-value="12"
data-symfony--ux-google-map--map-fit-bounds-to-markers-value="false"
data-symfony--ux-google-map--map-options-value="{&quot;mapId&quot;:null,&quot;gestureHandling&quot;:&quot;auto&quot;,&quot;backgroundColor&quot;:null,&quot;disableDoubleClickZoom&quot;:false,&quot;zoomControlOptions&quot;:{&quot;position&quot;:22},&quot;mapTypeControlOptions&quot;:{&quot;mapTypeIds&quot;:[],&quot;position&quot;:14,&quot;style&quot;:0},&quot;streetViewControlOptions&quot;:{&quot;position&quot;:22},&quot;fullscreenControlOptions&quot;:{&quot;position&quot;:20},&quot;@provider&quot;:&quot;google&quot;}"
data-symfony--ux-google-map--map-markers-value="[]"
data-symfony--ux-google-map--map-polygons-value="[]"
data-symfony--ux-google-map--map-polylines-value="[]"
data-symfony--ux-google-map--map-circles-value="[]"
data-symfony--ux-google-map--map-rectangles-value="[]"
></div>

View File

@@ -0,0 +1,15 @@
<!-- This HTML has been prettified for testing purposes, and may not represent the actual HTML output.
Run "php vendor/bin/phpunit -d --update-snapshots" to update the snapshot. -->
<div
data-controller="symfony--ux-google-map--map"
data-symfony--ux-google-map--map-provider-options-value="{&quot;apiKey&quot;:&quot;api_key&quot;}"
data-symfony--ux-google-map--map-center-value="{&quot;lat&quot;:48.8566,&quot;lng&quot;:2.3522}"
data-symfony--ux-google-map--map-zoom-value="12"
data-symfony--ux-google-map--map-fit-bounds-to-markers-value="false"
data-symfony--ux-google-map--map-options-value="{&quot;mapId&quot;:null,&quot;gestureHandling&quot;:&quot;auto&quot;,&quot;backgroundColor&quot;:null,&quot;disableDoubleClickZoom&quot;:false,&quot;zoomControlOptions&quot;:{&quot;position&quot;:22},&quot;mapTypeControlOptions&quot;:{&quot;mapTypeIds&quot;:[],&quot;position&quot;:14,&quot;style&quot;:0},&quot;streetViewControlOptions&quot;:{&quot;position&quot;:22},&quot;fullscreenControlOptions&quot;:{&quot;position&quot;:20},&quot;@provider&quot;:&quot;google&quot;}"
data-symfony--ux-google-map--map-markers-value="[]"
data-symfony--ux-google-map--map-polygons-value="[]"
data-symfony--ux-google-map--map-polylines-value="[]"
data-symfony--ux-google-map--map-circles-value="[]"
data-symfony--ux-google-map--map-rectangles-value="[]"
></div>