Skip to content

bug(Google maps): setters and getters fall out of sync #27480

Open
@diegoRain1995

Description

@diegoRain1995

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

As noted in #23093, the setZoom method has been removed from the component's api since you can set the property by using change detection (by setting the [zoom] attribute in the component. I'll refer to the variable used to set this attribute as myZoom).
This does not, however, go the other way; the components' zoomChanged method doesn't update automatically myZoom. This causes them to fall out of sync, which makes relying on the myZoom hard.

A temporary fix is to set

functionToCallOnZoomChanged() {
this.myZoom = this.mapComponent.getZoom()
}

This way you are always sure they are in sync and can use the same variable as a getter and a setter.
It's confusing to have the setter replaced by a variable that doesn't function as a getter as well.

Reproduction

Not needed

Expected Behavior

Not needed

Actual Behavior

Not needed

Environment

  • Angular: 16.0.6
  • CDK/Material: 16.0.2
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4A relatively minor issue that is not relevant to core functionsarea: google-maps

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions