components icon indicating copy to clipboard operation
components copied to clipboard

bug(google-maps): missing setZoom()

Open rbalet opened this issue 3 years ago • 4 comments
trafficstars

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

rbalet avatar Jul 14 '22 09:07 rbalet

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

amysorto avatar Jul 22 '22 16:07 amysorto

Hey @amysorto I would like to work on this issue if no one else is already using it. Thanks!

noobyogi0010 avatar Jul 30 '22 11:07 noobyogi0010

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 avatar Oct 09 '22 00:10 kgajera

@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 :)

rbalet avatar Oct 09 '22 06:10 rbalet

@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

rbalet avatar Nov 04 '22 14:11 rbalet

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 avatar Dec 12 '23 08:12 crisbeto

@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.

rbalet avatar Dec 12 '23 08:12 rbalet

There's already a way to set the zoom by assigning it like GoogleMap.zoom = <your zoom>.

crisbeto avatar Dec 12 '23 12:12 crisbeto