Skip to content

Commit

Permalink
[Map] Minor adjustements
Browse files Browse the repository at this point in the history
  • Loading branch information
Kocal committed Feb 15, 2025
1 parent a27bd08 commit 7f48247
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 7 deletions.
3 changes: 1 addition & 2 deletions src/Map/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
- Add `DistanceCalculatorInterface` interface and three implementations:
`HaversineDistanceCalculator`, `SphericalCosineDistanceCalculator` and `VincentyDistanceCalculator`.
- Add `CoordinateUtils` helper, to convert decimal coordinates (`43.2109`) in DMS (`56° 78' 90"`)

- Add property `$id` to `Marker`, `Polygon` and `Polyline` constructors
- Add parameter `id` to `Marker`, `Polygon` and `Polyline` constructors
- Add method `Map::removeMarker(string|Marker $markerOrId)`
- Add method `Map::removePolygon(string|Polygon $polygonOrId)`
- Add method `Map::removePolyline(string|Polyline $polylineOrId)`
Expand Down
5 changes: 5 additions & 0 deletions src/Map/src/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@

namespace Symfony\UX\Map;

/**
* @author Sylvain Blondeau <[email protected]>
*
* @internal
*/
interface Element
{
}
8 changes: 5 additions & 3 deletions src/Map/src/Elements.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
* Represents a collection of map elements.
*
* @author Sylvain Blondeau <[email protected]>
*
* @internal
*/
abstract class Elements
{
protected \SplObjectStorage $elements;
private \SplObjectStorage $elements;

public function __construct(
array $elements,
Expand All @@ -29,7 +31,7 @@ public function __construct(
}
}

public function add(Element $element): self
public function add(Element $element): static
{
$this->elements->attach($element, $element->id ?? $this->elements->getHash($element));

Expand All @@ -47,7 +49,7 @@ private function getElement(string $id): ?Element
return null;
}

public function remove(Element|string $elementOrId): self
public function remove(Element|string $elementOrId): static
{
if (\is_string($elementOrId)) {
$elementOrId = $this->getElement($elementOrId);
Expand Down
4 changes: 2 additions & 2 deletions src/Map/src/Map.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ final class Map

/**
* @param Marker[] $markers
* @param Polygon[] $polygons
* @param Polyline[] $polylines
* @param Polygone[] $polygons
*/
public function __construct(
private readonly ?string $rendererName = null,
Expand All @@ -40,8 +40,8 @@ public function __construct(
array $polylines = [],
) {
$this->markers = new Markers($markers);
$this->polylines = new Polylines($polylines);
$this->polygons = new Polygons($polygons);
$this->polylines = new Polylines($polylines);
}

public function getRendererName(): ?string
Expand Down
2 changes: 2 additions & 0 deletions src/Map/src/Markers.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* Represents a Marker collection.
*
* @author Sylvain Blondeau <[email protected]>
*
* @internal
*/
final class Markers extends Elements
{
Expand Down
2 changes: 2 additions & 0 deletions src/Map/src/Polygons.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* Represents a Polygon collection.
*
* @author Sylvain Blondeau <[email protected]>
*
* @internal
*/
final class Polygons extends Elements
{
Expand Down
2 changes: 2 additions & 0 deletions src/Map/src/Polylines.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* Represents a Polyline collection.
*
* @author Sylvain Blondeau <[email protected]>
*
* @internal
*/
final class Polylines extends Elements
{
Expand Down

0 comments on commit 7f48247

Please sign in to comment.