-
-
Notifications
You must be signed in to change notification settings - Fork 338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Map] markers, polygons and polylines removal #2547
base: 2.x
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -136,6 +136,29 @@ You can add markers to a map using the ``addMarker()`` method:: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Remove elements from Map | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
You can remove markers, polygons and polylines from a map using the ``removeMarker(Marker $marker)``, ``removePolyline(Polyline $polyline)`` and ``removePolygon(Polygon $polygon)`` methods:: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
When you create Marker, Polygon or Polyne, you can add an identifier in construct : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
$departureMarker = new Marker ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
position: new Point(45.7640, 4.8357), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
title: 'Lyon', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
identifier: 'departure' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
then retrieve the marker with ``Map::getMarker(string $identifier)``, also works with ``Map::getPolygon(string $identifier)`` and ``Map::getPolyline(string $identifier)``. It can be useful to remove an element from its identifier. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
$map->addMarker($departureMarker); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// remove marker with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
$map->removeMarker($departureMarker) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
$map->removeMarker($map->getMarker('departure')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+142
to
+161
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Add Polygons | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
~~~~~~~~~~~~ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -11,6 +11,7 @@ | |||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
namespace Symfony\UX\Map; | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
use SplObjectStorage; | ||||||||||||||||||||||||||||||||||||||
use Symfony\UX\Map\Exception\InvalidArgumentException; | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||||
|
@@ -29,19 +30,18 @@ public function __construct( | |||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||||
* @var array<Marker> | ||||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||
private array $markers = [], | ||||||||||||||||||||||||||||||||||||||
private SplObjectStorage $markers = new SplObjectStorage(), | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a nice improvement, but I would like to see this logic (with methods Something like:
Anyway, changing things like that is a BC for users using We can change it to this, which is BC compatbile:
Suggested change
Then, add a new property |
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||||
* @var array<Polygon> | ||||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||
private array $polygons = [], | ||||||||||||||||||||||||||||||||||||||
private SplObjectStorage $polygons = new SplObjectStorage(), | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||||
* @var array<Polyline> | ||||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||
private array $polylines = [], | ||||||||||||||||||||||||||||||||||||||
) { | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
private SplObjectStorage $polylines = new SplObjectStorage(), | ||||||||||||||||||||||||||||||||||||||
) {} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
public function getRendererName(): ?string | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
|
@@ -86,23 +86,99 @@ public function hasOptions(): bool | |||||||||||||||||||||||||||||||||||||
return null !== $this->options; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
public function getMarker(string $identifier): ?Marker | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
foreach ($this->markers as $marker) { | ||||||||||||||||||||||||||||||||||||||
if ($this->markers->offsetGet($marker) === $identifier) { | ||||||||||||||||||||||||||||||||||||||
return $marker; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
return null; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
Comment on lines
+90
to
+99
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To remove (and similar methods too) |
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
public function addMarker(Marker $marker): self | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
$this->markers[] = $marker; | ||||||||||||||||||||||||||||||||||||||
$this->markers->attach($marker, $marker->identifier ?? $this->markers->getHash($marker)); | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
return $this; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
public function removeMarker(?Marker $marker): self | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
if ($marker === null) { | ||||||||||||||||||||||||||||||||||||||
return $this; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
if ($this->markers->contains($marker)) { | ||||||||||||||||||||||||||||||||||||||
$this->markers->detach($marker); | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
return $this; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
Comment on lines
+109
to
120
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To apply to similar methods too:
Suggested change
|
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
public function getPolygon(string $identifier): ?Polygon | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
foreach ($this->polygons as $polygon) { | ||||||||||||||||||||||||||||||||||||||
if ($this->polygons->offsetGet($polygon) === $identifier) { | ||||||||||||||||||||||||||||||||||||||
return $polygon; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
return null; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
public function addPolygon(Polygon $polygon): self | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
$this->polygons[] = $polygon; | ||||||||||||||||||||||||||||||||||||||
$this->polygons->attach($polygon, $polygon->identifier ?? $this->polygons->getHash($polygon)); | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
return $this; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
public function removePolygon(?Polygon $polygon): self | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
if ($polygon === null) { | ||||||||||||||||||||||||||||||||||||||
return $this; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
if ($this->polygons->contains($polygon)) { | ||||||||||||||||||||||||||||||||||||||
$this->polygons->detach($polygon); | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
return $this; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
public function getPolyline(string $identifier): ?Polyline | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
foreach ($this->polylines as $polyline) { | ||||||||||||||||||||||||||||||||||||||
if ($this->polylines->offsetGet($polyline) === $identifier) { | ||||||||||||||||||||||||||||||||||||||
return $polyline; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
return null; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
public function addPolyline(Polyline $polyline): self | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
$this->polylines[] = $polyline; | ||||||||||||||||||||||||||||||||||||||
$this->polylines->attach($polyline, $polyline->identifier ?? $this->polylines->getHash($polyline)); | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
return $this; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
public function removePolyline(?Polyline $polyline): self | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
if ($polyline === null) { | ||||||||||||||||||||||||||||||||||||||
return $this; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
if ($this->polylines->contains($polyline)) { | ||||||||||||||||||||||||||||||||||||||
$this->polylines->detach($polyline); | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
return $this; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
@@ -124,12 +200,73 @@ public function toArray(): array | |||||||||||||||||||||||||||||||||||||
'zoom' => $this->zoom, | ||||||||||||||||||||||||||||||||||||||
'fitBoundsToMarkers' => $this->fitBoundsToMarkers, | ||||||||||||||||||||||||||||||||||||||
'options' => $this->options ? MapOptionsNormalizer::normalize($this->options) : [], | ||||||||||||||||||||||||||||||||||||||
'markers' => array_map(static fn (Marker $marker) => $marker->toArray(), $this->markers), | ||||||||||||||||||||||||||||||||||||||
'polygons' => array_map(static fn (Polygon $polygon) => $polygon->toArray(), $this->polygons), | ||||||||||||||||||||||||||||||||||||||
'polylines' => array_map(static fn (Polyline $polyline) => $polyline->toArray(), $this->polylines), | ||||||||||||||||||||||||||||||||||||||
'markers' => $this->markersToArray(), | ||||||||||||||||||||||||||||||||||||||
'polygons' => $this->polygonsToArray(), | ||||||||||||||||||||||||||||||||||||||
'polylines' => $this->polylinesToArray(), | ||||||||||||||||||||||||||||||||||||||
Comment on lines
+203
to
+205
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||
]; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
private function markersToArray(): array | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
foreach ($this->markers as $marker) { | ||||||||||||||||||||||||||||||||||||||
$markers[] = $marker->toArray(); | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
return $markers ?? []; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
private static function markersFromArray(array $markers): SplObjectStorage | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
$markerObjects = new SplObjectStorage(); | ||||||||||||||||||||||||||||||||||||||
foreach ($markers as $marker) { | ||||||||||||||||||||||||||||||||||||||
$markerObject = Marker::fromArray($marker); | ||||||||||||||||||||||||||||||||||||||
$markerObjects->attach($markerObject, $markerObject->identifier); | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
return $markerObjects; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
private function polygonsToArray(): array | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
foreach ($this->polygons as $polygon) { | ||||||||||||||||||||||||||||||||||||||
$polygons[] = $polygon->toArray(); | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
return $polygons ?? []; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
private static function polygonsFromArray(array $polygons): SplObjectStorage | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
$polygonObjects = new SplObjectStorage(); | ||||||||||||||||||||||||||||||||||||||
foreach ($polygons as $polygon) { | ||||||||||||||||||||||||||||||||||||||
$polygonObject = Polygon::fromArray($polygon); | ||||||||||||||||||||||||||||||||||||||
$polygonObjects->attach($polygonObject, $polygonObject->identifier); | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
return $polygonObjects; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
private function polylinesToArray(): array | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
foreach ($this->polylines as $polyline) { | ||||||||||||||||||||||||||||||||||||||
$polylines[] = $polyline->toArray(); | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
return $polylines ?? []; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
private static function polylinesFromArray(array $polylines): SplObjectStorage | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
$polylineObjects = new SplObjectStorage(); | ||||||||||||||||||||||||||||||||||||||
foreach ($polylines as $polyline) { | ||||||||||||||||||||||||||||||||||||||
$polylineObject = Polyline::fromArray($polyline); | ||||||||||||||||||||||||||||||||||||||
$polylineObjects->attach($polylineObject, $polylineObject->identifier); | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
return $polylineObjects; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
Comment on lines
+209
to
+268
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To remove / externalize into |
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||||
* @param array{ | ||||||||||||||||||||||||||||||||||||||
* center?: array{lat: float, lng: float}, | ||||||||||||||||||||||||||||||||||||||
|
@@ -159,23 +296,23 @@ public static function fromArray(array $map): self | |||||||||||||||||||||||||||||||||||||
$map['fitBoundsToMarkers'] = false; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
$map['markers'] ??= []; | ||||||||||||||||||||||||||||||||||||||
$map['markers'] ??= new SplObjectStorage(); | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be reverted, |
||||||||||||||||||||||||||||||||||||||
if (!\is_array($map['markers'])) { | ||||||||||||||||||||||||||||||||||||||
throw new InvalidArgumentException('The "markers" parameter must be an array.'); | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
$map['markers'] = array_map(Marker::fromArray(...), $map['markers']); | ||||||||||||||||||||||||||||||||||||||
$map['markers'] = self::markersFromArray($map['markers']); | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And same below |
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
$map['polygons'] ??= []; | ||||||||||||||||||||||||||||||||||||||
$map['polygons'] ??= new SplObjectStorage(); | ||||||||||||||||||||||||||||||||||||||
if (!\is_array($map['polygons'])) { | ||||||||||||||||||||||||||||||||||||||
throw new InvalidArgumentException('The "polygons" parameter must be an array.'); | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
$map['polygons'] = array_map(Polygon::fromArray(...), $map['polygons']); | ||||||||||||||||||||||||||||||||||||||
$map['polygons'] = self::polygonsFromArray($map['polygons']); | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
$map['polylines'] ??= []; | ||||||||||||||||||||||||||||||||||||||
$map['polylines'] ??= new SplObjectStorage(); | ||||||||||||||||||||||||||||||||||||||
if (!\is_array($map['polylines'])) { | ||||||||||||||||||||||||||||||||||||||
throw new InvalidArgumentException('The "polylines" parameter must be an array.'); | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
$map['polylines'] = array_map(Polyline::fromArray(...), $map['polylines']); | ||||||||||||||||||||||||||||||||||||||
$map['polylines'] = self::polylinesFromArray($map['polylines']); | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
return new self(...$map); | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -25,10 +25,11 @@ | |||||
* use them later JavaScript side | ||||||
*/ | ||||||
public function __construct( | ||||||
private Point $position, | ||||||
private ?string $title = null, | ||||||
private ?InfoWindow $infoWindow = null, | ||||||
private array $extra = [], | ||||||
public Point $position, | ||||||
public ?string $title = null, | ||||||
public ?InfoWindow $infoWindow = null, | ||||||
public array $extra = [], | ||||||
public ?string $identifier = null, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same for other elements |
||||||
) { | ||||||
} | ||||||
|
||||||
|
@@ -38,6 +39,7 @@ public function __construct( | |||||
* title: string|null, | ||||||
* infoWindow: array<string, mixed>|null, | ||||||
* extra: array, | ||||||
* identifier: string|null | ||||||
* } | ||||||
*/ | ||||||
public function toArray(): array | ||||||
|
@@ -47,6 +49,7 @@ public function toArray(): array | |||||
'title' => $this->title, | ||||||
'infoWindow' => $this->infoWindow?->toArray(), | ||||||
'extra' => $this->extra, | ||||||
'identifier' => $this->identifier, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
You must also update TypeScript types definition to reflect this change. |
||||||
]; | ||||||
} | ||||||
|
||||||
|
@@ -56,6 +59,7 @@ public function toArray(): array | |||||
* title: string|null, | ||||||
* infoWindow: array<string, mixed>|null, | ||||||
* extra: array, | ||||||
* identifier: string|null | ||||||
* } $marker | ||||||
* | ||||||
* @internal | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.