components
components copied to clipboard
bug(google-maps): missing setZoom()
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
the setZoom() method is missing in the new angular google-maps component.
Reproduction
use "@angular/google-maps": "14.0.4",
Expected Behavior
being able to change the zoom of the map as follow
@ViewChild('googleMap', { static: true }) googleMap: GoogleMap
setZoom(zoom: number) {
this.googleMap.setZoom(zoom)
}
<google-map
#googleMap
width="100%"
height="100%"
[options]="options"
>
</google-map>
Actual Behavior
Property 'setZoom' does not exist on type 'GoogleMap'. Did you mean 'getZoom'?
Environment
- Angular: v14.0.6
- CDK/Material: 14.0.4
- Browser(s): Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): Windows 10
Seems like we are using this function already so this seems like it won't be difficult to add: https://github.com/angular/components/blob/main/src/google-maps/google-map/google-map.ts#L290
Hey @amysorto I would like to work on this issue if no one else is already using it. Thanks!
There's already a zoom input that allows changing the zoom: https://github.com/angular/components/blob/main/src/google-maps/google-map/google-map.ts#L95
It seems like exposing setZoom would be duplicative. If we make this change, there are other "set" functions we would need expose too, for example setCenter.
@kgajera correct me if I'm wrong,
But the default Google map component have the zoom exposed as input and the setZoom() as function.
So this isn't really a duplicate
Additionally, since this library doesn't have any documentation other than "look what the original Google nap component does" I would expect it to do the same and not having to look myself into the code to see the reason why this isn't working (what I actually have to do..)
Or we could add a documentation that explain the difference, but I'm quite sure this make less sense .
As people mentioned they are ready to implement themselves and create a merge request, just need an approval here :)
@kgajera @amysorto @amysorto Wait a bit and still no real answer.
Since this is a really straight forward I've implemented it and made a pull-request
Hope this will help that feature get implemented
Closing since while it's confusing, it's currently working as expected. The zoom level is meant to be set through the zoom input. We'll look into making this less confusing in the future.
@crisbeto Sorry to be annoying about that matter, but why is my pull request not accepted?
This is just a nice new feature, it remove the confusion and make it more like the original google API.
So I'm a bit lost on the why this did get rejected.
There's already a way to set the zoom by assigning it like GoogleMap.zoom = <your zoom>.