Skip to content
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][Google] Add maxZoom to GoogleOptions #2520

Open
wants to merge 3 commits into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Map/src/Bridge/Google/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## Unreleased
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We know that the next version will be 2.23, so let's add it :)

Suggested change
## Unreleased
## 2.23


- Add support for the maxZoom option
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Add support for the maxZoom option
- Add support for the `maxZoom` option


## 2.22

- Add support for configuring a default Map ID
Expand Down
1 change: 1 addition & 0 deletions src/Map/src/Bridge/Google/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ $googleOptions = (new GoogleOptions())

->gestureHandling(GestureHandling::GREEDY)
->backgroundColor('#f00')
->maxZoom(10)
->doubleClickZoom(true)
->zoomControlOptions(new ZoomControlOptions(
position: ControlPosition::BLOCK_START_INLINE_END,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { LoaderOptions } from '@googlemaps/js-api-loader';
import AbstractMapController from '@symfony/ux-map';
import type { InfoWindowWithoutPositionDefinition, MarkerDefinition, Point, PolygonDefinition, PolylineDefinition } from '@symfony/ux-map';
type MapOptions = Pick<google.maps.MapOptions, 'mapId' | 'gestureHandling' | 'backgroundColor' | 'disableDoubleClickZoom' | 'zoomControl' | 'zoomControlOptions' | 'mapTypeControl' | 'mapTypeControlOptions' | 'streetViewControl' | 'streetViewControlOptions' | 'fullscreenControl' | 'fullscreenControlOptions'>;
type MapOptions = Pick<google.maps.MapOptions, 'mapId' | 'gestureHandling' | 'backgroundColor' | 'maxZoom' | 'disableDoubleClickZoom' | 'zoomControl' | 'zoomControlOptions' | 'mapTypeControl' | 'mapTypeControlOptions' | 'streetViewControl' | 'streetViewControlOptions' | 'fullscreenControl' | 'fullscreenControlOptions'>;
export default class extends AbstractMapController<MapOptions, google.maps.Map, google.maps.marker.AdvancedMarkerElementOptions, google.maps.marker.AdvancedMarkerElement, google.maps.InfoWindowOptions, google.maps.InfoWindow, google.maps.PolygonOptions, google.maps.Polygon, google.maps.PolylineOptions, google.maps.Polyline> {
providerOptionsValue: Pick<LoaderOptions, 'apiKey' | 'id' | 'language' | 'region' | 'nonce' | 'retries' | 'url' | 'version' | 'libraries'>;
map: google.maps.Map;
Expand Down
1 change: 1 addition & 0 deletions src/Map/src/Bridge/Google/assets/src/map_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type MapOptions = Pick<
| 'mapId'
| 'gestureHandling'
| 'backgroundColor'
| 'maxZoom'
| 'disableDoubleClickZoom'
| 'zoomControl'
| 'zoomControlOptions'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('GoogleMapsController', () => {
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="7"
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-options-value="{&quot;mapId&quot;:null,&quot;gestureHandling&quot;:&quot;auto&quot;,&quot;backgroundColor&quot;:null,&quot;maxZoom&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="[]"
Expand Down
9 changes: 9 additions & 0 deletions src/Map/src/Bridge/Google/src/GoogleOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function __construct(
private ?string $mapId = null,
private GestureHandling $gestureHandling = GestureHandling::AUTO,
private ?string $backgroundColor = null,
private ?int $maxZoom = null,
private bool $disableDoubleClickZoom = false,
private bool $zoomControl = true,
private ZoomControlOptions $zoomControlOptions = new ZoomControlOptions(),
Expand Down Expand Up @@ -58,6 +59,13 @@ public function gestureHandling(GestureHandling $gestureHandling): self
return $this;
}

public function maxZoom(?int $maxZoom): self
{
$this->maxZoom = $maxZoom;

return $this;
}

public function backgroundColor(?string $backgroundColor): self
{
$this->backgroundColor = $backgroundColor;
Expand Down Expand Up @@ -173,6 +181,7 @@ public function toArray(): array
'mapId' => $this->mapId,
'gestureHandling' => $this->gestureHandling->value,
'backgroundColor' => $this->backgroundColor,
'maxZoom' => $this->maxZoom,
'disableDoubleClickZoom' => $this->disableDoubleClickZoom,
];

Expand Down
3 changes: 3 additions & 0 deletions src/Map/src/Bridge/Google/tests/GoogleOptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function testWithMinimalConfiguration(): void
'mapId' => null,
'gestureHandling' => 'auto',
'backgroundColor' => null,
'maxZoom' => null,
'disableDoubleClickZoom' => false,
'zoomControlOptions' => [
'position' => ControlPosition::INLINE_END_BLOCK_END->value,
Expand All @@ -53,6 +54,7 @@ public function testWithMinimalConfigurationAndWithoutControls(): void
mapId: 'abcdefgh12345678',
gestureHandling: GestureHandling::GREEDY,
backgroundColor: '#f00',
maxZoom: 10,
disableDoubleClickZoom: true,
zoomControl: false,
mapTypeControl: false,
Expand All @@ -64,6 +66,7 @@ public function testWithMinimalConfigurationAndWithoutControls(): void
'mapId' => 'abcdefgh12345678',
'gestureHandling' => GestureHandling::GREEDY->value,
'backgroundColor' => '#f00',
'maxZoom' => 10,
'disableDoubleClickZoom' => true,
], $options->toArray());

Expand Down
Loading
Loading