Skip to content

bug(google-maps): Zoom not updated on centerChange #24495

Open
@cesarcgfg

Description

@cesarcgfg

What are you trying to do?

Trying to zoom map after center change:
google-maps.component.html

<google-map
    height="600px"
    width="100%"
    [center]="center"
    [zoom]="zoom"
    (mapMousemove)="move($event)"
    (centerChanged)="centerChanged()">
    <map-marker
      *ngFor="let markerPosition of markerPositions"
      [position]="markerPosition"
      [options]="markerOptions"
      (mapClick)="openInfoWindow(marker)"
    ></map-marker>
</google-map>

google-maps.component.ts

export class GoogleMapsComponent {
  @Input() center!: google.maps.LatLngLiteral;
  zoom = 17;
...

 centerChanged() {
    console.log('center changed');
    this.zoom = 17;
  }

What troubleshooting steps have you tried?

Zoom is not changed

Reproduction

Steps to reproduce:

  1. User changes zoom
  2. User clicks on marker link that updates center variable.
  3. Center is changed, console.log is fired but zoom is not updated

Environment

  • Angular: 12.2.6
  • Browser(s): Firefox/Chrome
  • Operating System Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: google-maps

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions