Angular-google-maps: Can't get zoom on change

Created on 27 Oct 2016  Â·  6Comments  Â·  Source: SebastianM/angular-google-maps

Issue description
I've bound the zoomChange output to a simple logging function. However, I can't get the zoom level.

Current behavior
Seems like no arguments are being passed to my callback

Expected/desired behavior
Zoom should be passed on each call

angular2 & angular2-google-maps version
Angular2 2.0.0
AGM 0.15.0

<ion-content class="map">
  <sebm-google-map [latitude]="lat"
                   [longitude]="lng"
                   [zoom]="16"
                   (zoomChange)="zoomChange(z)">
  </sebm-google-map>
</ion-content>
    zoomChange(event){
    console.log(event);
    }

every time I zoom, I get undefined in the console.

discussion / question

Most helpful comment

You need to change z into $event as argument in the template (it's by design in Angular). z really is undefined in your template.

All 6 comments

You need to change z into $event as argument in the template (it's by design in Angular). z really is undefined in your template.

@lazarljubenovic thanks! That works.

Any idea on how to get the center of the map programmatically? Say, after the user has dragged it around a bit?

@jonathan-chin There's centerChange output.

thanks Lazar. I believe I tried that before but it fired multiple times on
drag. so I ideally want to listen for the idle event and get the center
once.

On Oct 31, 2016 2:28 PM, "Lazar Ljubenović" [email protected]
wrote:

@jonathan-chin https://github.com/jonathan-chin There's centerChange
https://github.com/SebastianM/angular2-google-maps/blob/758d3e089823acc45451d64f3e5b89047809e412/src/core/directives/google-map.ts#L207
output.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/SebastianM/angular2-google-maps/issues/724#issuecomment-257378543,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHK8tHHllb2cRInEW8n0dChH7zgOs2JLks5q5jMxgaJpZM4Kiy0A
.

I don't think it's currently supported (you can check here and here in the source); a quick fix I can think of at the moment is using RxJS and debouncing the change. The event is still fired rapidly, but you can apply debounceTime to the Subject and work from there.

@jonathan-chin you can combine the (idle) output with the (centerChange) event. So track changes from the centerChange output when an idle gets emitted, you can start your logic. Does this help?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DeveloperAdd007 picture DeveloperAdd007  Â·  3Comments

matishw picture matishw  Â·  3Comments

stot3 picture stot3  Â·  3Comments

shedar picture shedar  Â·  4Comments

alexweber picture alexweber  Â·  4Comments