[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 cfcf0b95c0
commit e0ca4e1a5e
6 changed files with 125 additions and 0 deletions

View File

@@ -69,6 +69,16 @@ class LeafletRendererTest extends RendererTestCase
->removeMarker('marker2'),
];
yield 'with all markers removed with removeAllMarkers()' => [
'renderer' => new LeafletRenderer(new StimulusHelper(null), new UxIconRenderer(null)),
'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 LeafletRenderer(new StimulusHelper(null), new UxIconRenderer(null)),
'map' => (new Map())
@@ -89,6 +99,16 @@ class LeafletRendererTest 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'), id: 'polygon2')),
];
yield 'with all polygons removed with removeAllPolygons()' => [
'renderer' => new LeafletRenderer(new StimulusHelper(null), new UxIconRenderer(null)),
'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 LeafletRenderer(new StimulusHelper(null), new UxIconRenderer(null)),
'map' => (new Map())
@@ -98,6 +118,16 @@ class LeafletRendererTest 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: 'Polyline'), id: 'polyline2')),
];
yield 'with all polylines removed with removeAllPolylines()' => [
'renderer' => new LeafletRenderer(new StimulusHelper(null), new UxIconRenderer(null)),
'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 LeafletRenderer(new StimulusHelper(null), new UxIconRenderer(null)),
'map' => (new Map())
@@ -107,6 +137,16 @@ class LeafletRendererTest extends RendererTestCase
->addCircle(new Circle(center: new Point(1.1, 2.2), radius: 500, infoWindow: new InfoWindow(content: 'Circle'), id: 'circle2')),
];
yield 'with all circles removed with removeAllCircles()' => [
'renderer' => new LeafletRenderer(new StimulusHelper(null), new UxIconRenderer(null)),
'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 LeafletRenderer(new StimulusHelper(null), new UxIconRenderer(null)),
'map' => (new Map())
@@ -125,6 +165,16 @@ class LeafletRendererTest extends RendererTestCase
)),
];
yield 'with all rectangles removed with removeAllRectangles()' => [
'renderer' => new LeafletRenderer(new StimulusHelper(null), new UxIconRenderer(null)),
'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 'markers with icons' => [
'renderer' => new LeafletRenderer(
new StimulusHelper(null),

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-leaflet-map--map"
data-symfony--ux-leaflet-map--map-provider-options-value="{}"
data-symfony--ux-leaflet-map--map-center-value="{&quot;lat&quot;:48.8566,&quot;lng&quot;:2.3522}"
data-symfony--ux-leaflet-map--map-zoom-value="12"
data-symfony--ux-leaflet-map--map-fit-bounds-to-markers-value="false"
data-symfony--ux-leaflet-map--map-options-value="{&quot;tileLayer&quot;:{&quot;url&quot;:&quot;https:\/\/tile.openstreetmap.org\/{z}\/{x}\/{y}.png&quot;,&quot;attribution&quot;:&quot;\u00a9 &lt;a href=\&quot;https:\/\/www.openstreetmap.org\/copyright\&quot;&gt;OpenStreetMap&lt;\/a&gt;&quot;,&quot;options&quot;:[]},&quot;attributionControlOptions&quot;:{&quot;position&quot;:&quot;bottomright&quot;,&quot;prefix&quot;:&quot;Leaflet&quot;},&quot;zoomControlOptions&quot;:{&quot;position&quot;:&quot;topleft&quot;,&quot;zoomInText&quot;:&quot;&lt;span aria-hidden=\&quot;true\&quot;&gt;+&lt;\/span&gt;&quot;,&quot;zoomInTitle&quot;:&quot;Zoom in&quot;,&quot;zoomOutText&quot;:&quot;&lt;span aria-hidden=\&quot;true\&quot;&gt;&amp;#x2212;&lt;\/span&gt;&quot;,&quot;zoomOutTitle&quot;:&quot;Zoom out&quot;},&quot;@provider&quot;:&quot;leaflet&quot;}"
data-symfony--ux-leaflet-map--map-markers-value="[]"
data-symfony--ux-leaflet-map--map-polygons-value="[]"
data-symfony--ux-leaflet-map--map-polylines-value="[]"
data-symfony--ux-leaflet-map--map-circles-value="[]"
data-symfony--ux-leaflet-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-leaflet-map--map"
data-symfony--ux-leaflet-map--map-provider-options-value="{}"
data-symfony--ux-leaflet-map--map-center-value="{&quot;lat&quot;:48.8566,&quot;lng&quot;:2.3522}"
data-symfony--ux-leaflet-map--map-zoom-value="12"
data-symfony--ux-leaflet-map--map-fit-bounds-to-markers-value="false"
data-symfony--ux-leaflet-map--map-options-value="{&quot;tileLayer&quot;:{&quot;url&quot;:&quot;https:\/\/tile.openstreetmap.org\/{z}\/{x}\/{y}.png&quot;,&quot;attribution&quot;:&quot;\u00a9 &lt;a href=\&quot;https:\/\/www.openstreetmap.org\/copyright\&quot;&gt;OpenStreetMap&lt;\/a&gt;&quot;,&quot;options&quot;:[]},&quot;attributionControlOptions&quot;:{&quot;position&quot;:&quot;bottomright&quot;,&quot;prefix&quot;:&quot;Leaflet&quot;},&quot;zoomControlOptions&quot;:{&quot;position&quot;:&quot;topleft&quot;,&quot;zoomInText&quot;:&quot;&lt;span aria-hidden=\&quot;true\&quot;&gt;+&lt;\/span&gt;&quot;,&quot;zoomInTitle&quot;:&quot;Zoom in&quot;,&quot;zoomOutText&quot;:&quot;&lt;span aria-hidden=\&quot;true\&quot;&gt;&amp;#x2212;&lt;\/span&gt;&quot;,&quot;zoomOutTitle&quot;:&quot;Zoom out&quot;},&quot;@provider&quot;:&quot;leaflet&quot;}"
data-symfony--ux-leaflet-map--map-markers-value="[]"
data-symfony--ux-leaflet-map--map-polygons-value="[]"
data-symfony--ux-leaflet-map--map-polylines-value="[]"
data-symfony--ux-leaflet-map--map-circles-value="[]"
data-symfony--ux-leaflet-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-leaflet-map--map"
data-symfony--ux-leaflet-map--map-provider-options-value="{}"
data-symfony--ux-leaflet-map--map-center-value="{&quot;lat&quot;:48.8566,&quot;lng&quot;:2.3522}"
data-symfony--ux-leaflet-map--map-zoom-value="12"
data-symfony--ux-leaflet-map--map-fit-bounds-to-markers-value="false"
data-symfony--ux-leaflet-map--map-options-value="{&quot;tileLayer&quot;:{&quot;url&quot;:&quot;https:\/\/tile.openstreetmap.org\/{z}\/{x}\/{y}.png&quot;,&quot;attribution&quot;:&quot;\u00a9 &lt;a href=\&quot;https:\/\/www.openstreetmap.org\/copyright\&quot;&gt;OpenStreetMap&lt;\/a&gt;&quot;,&quot;options&quot;:[]},&quot;attributionControlOptions&quot;:{&quot;position&quot;:&quot;bottomright&quot;,&quot;prefix&quot;:&quot;Leaflet&quot;},&quot;zoomControlOptions&quot;:{&quot;position&quot;:&quot;topleft&quot;,&quot;zoomInText&quot;:&quot;&lt;span aria-hidden=\&quot;true\&quot;&gt;+&lt;\/span&gt;&quot;,&quot;zoomInTitle&quot;:&quot;Zoom in&quot;,&quot;zoomOutText&quot;:&quot;&lt;span aria-hidden=\&quot;true\&quot;&gt;&amp;#x2212;&lt;\/span&gt;&quot;,&quot;zoomOutTitle&quot;:&quot;Zoom out&quot;},&quot;@provider&quot;:&quot;leaflet&quot;}"
data-symfony--ux-leaflet-map--map-markers-value="[]"
data-symfony--ux-leaflet-map--map-polygons-value="[]"
data-symfony--ux-leaflet-map--map-polylines-value="[]"
data-symfony--ux-leaflet-map--map-circles-value="[]"
data-symfony--ux-leaflet-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-leaflet-map--map"
data-symfony--ux-leaflet-map--map-provider-options-value="{}"
data-symfony--ux-leaflet-map--map-center-value="{&quot;lat&quot;:48.8566,&quot;lng&quot;:2.3522}"
data-symfony--ux-leaflet-map--map-zoom-value="12"
data-symfony--ux-leaflet-map--map-fit-bounds-to-markers-value="false"
data-symfony--ux-leaflet-map--map-options-value="{&quot;tileLayer&quot;:{&quot;url&quot;:&quot;https:\/\/tile.openstreetmap.org\/{z}\/{x}\/{y}.png&quot;,&quot;attribution&quot;:&quot;\u00a9 &lt;a href=\&quot;https:\/\/www.openstreetmap.org\/copyright\&quot;&gt;OpenStreetMap&lt;\/a&gt;&quot;,&quot;options&quot;:[]},&quot;attributionControlOptions&quot;:{&quot;position&quot;:&quot;bottomright&quot;,&quot;prefix&quot;:&quot;Leaflet&quot;},&quot;zoomControlOptions&quot;:{&quot;position&quot;:&quot;topleft&quot;,&quot;zoomInText&quot;:&quot;&lt;span aria-hidden=\&quot;true\&quot;&gt;+&lt;\/span&gt;&quot;,&quot;zoomInTitle&quot;:&quot;Zoom in&quot;,&quot;zoomOutText&quot;:&quot;&lt;span aria-hidden=\&quot;true\&quot;&gt;&amp;#x2212;&lt;\/span&gt;&quot;,&quot;zoomOutTitle&quot;:&quot;Zoom out&quot;},&quot;@provider&quot;:&quot;leaflet&quot;}"
data-symfony--ux-leaflet-map--map-markers-value="[]"
data-symfony--ux-leaflet-map--map-polygons-value="[]"
data-symfony--ux-leaflet-map--map-polylines-value="[]"
data-symfony--ux-leaflet-map--map-circles-value="[]"
data-symfony--ux-leaflet-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-leaflet-map--map"
data-symfony--ux-leaflet-map--map-provider-options-value="{}"
data-symfony--ux-leaflet-map--map-center-value="{&quot;lat&quot;:48.8566,&quot;lng&quot;:2.3522}"
data-symfony--ux-leaflet-map--map-zoom-value="12"
data-symfony--ux-leaflet-map--map-fit-bounds-to-markers-value="false"
data-symfony--ux-leaflet-map--map-options-value="{&quot;tileLayer&quot;:{&quot;url&quot;:&quot;https:\/\/tile.openstreetmap.org\/{z}\/{x}\/{y}.png&quot;,&quot;attribution&quot;:&quot;\u00a9 &lt;a href=\&quot;https:\/\/www.openstreetmap.org\/copyright\&quot;&gt;OpenStreetMap&lt;\/a&gt;&quot;,&quot;options&quot;:[]},&quot;attributionControlOptions&quot;:{&quot;position&quot;:&quot;bottomright&quot;,&quot;prefix&quot;:&quot;Leaflet&quot;},&quot;zoomControlOptions&quot;:{&quot;position&quot;:&quot;topleft&quot;,&quot;zoomInText&quot;:&quot;&lt;span aria-hidden=\&quot;true\&quot;&gt;+&lt;\/span&gt;&quot;,&quot;zoomInTitle&quot;:&quot;Zoom in&quot;,&quot;zoomOutText&quot;:&quot;&lt;span aria-hidden=\&quot;true\&quot;&gt;&amp;#x2212;&lt;\/span&gt;&quot;,&quot;zoomOutTitle&quot;:&quot;Zoom out&quot;},&quot;@provider&quot;:&quot;leaflet&quot;}"
data-symfony--ux-leaflet-map--map-markers-value="[]"
data-symfony--ux-leaflet-map--map-polygons-value="[]"
data-symfony--ux-leaflet-map--map-polylines-value="[]"
data-symfony--ux-leaflet-map--map-circles-value="[]"
data-symfony--ux-leaflet-map--map-rectangles-value="[]"
></div>