Skip to content

Commit 3460778

Browse files
author
Danny van Wijk
committed
[Map] Use fitboundstomarker configuration
1 parent bb13764 commit 3460778

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/Map/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# CHANGELOG
22

3+
## 2.27
4+
5+
- When fitBoundsToMarkers is enabled, the map will now automatically adjust the zoom level to fit all markers within the viewport, ensuring that all markers are visible without any overlap.
6+
This setting now works also with LiveComponents. Before this change, the map would not adjust the zoom level when using LiveComponents, which could lead to markers being outside the visible area of the map.
7+
38
## 2.26
49

510
- Add support for creating `Polygon` with holes, by passing an array of `array<Point>` as `points` parameter to the `Polygon` constructor, e.g.:

src/Map/doc/index.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,9 @@ You can retrieve the map instance using the ``getMap()`` method, and change the
655655
// Change the map zoom
656656
$this->getMap()->zoom(6);
657657

658+
// Disable the automatic fitting of bounds to markers
659+
$this->getMap()->fitBoundsToMarkers(false);
660+
658661
// Add a new marker
659662
$this->getMap()->addMarker(new Marker(position: new Point(43.2965, 5.3698), title: 'Marseille', infoWindow: new InfoWindow('Marseille')));
660663

src/Map/src/Map.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,6 @@ public function toArray(): array
167167
*/
168168
public static function fromArray(array $map): self
169169
{
170-
$map['fitBoundsToMarkers'] = true;
171-
172170
if (isset($map['options'])) {
173171
$map['options'] = [] === $map['options'] ? null : MapOptionsNormalizer::denormalize($map['options']);
174172
}
@@ -177,10 +175,6 @@ public static function fromArray(array $map): self
177175
$map['center'] = Point::fromArray($map['center']);
178176
}
179177

180-
if (isset($map['zoom']) || isset($map['center'])) {
181-
$map['fitBoundsToMarkers'] = false;
182-
}
183-
184178
$map['markers'] ??= [];
185179
if (!\is_array($map['markers'])) {
186180
throw new InvalidArgumentException('The "markers" parameter must be an array.');

0 commit comments

Comments
 (0)