In HTML file-----
<agm-map #gm [latitude]="latitude"
[longitude]="longitude"
[zoom]="zoom"
(zoomChange)="changeMapZoom($event)" ---> You need to add this
>
....
....
</agm-map>
And in TS file
changeMapZoom(e: any): any {
this.zoom = e; ---> here i set zoom level according to my need.
}
You can pass this function in any function with zoom level value.
For ex. you need to search location then see below code.
this.mapsAPILoader.load().then(() => {
this.setCurrentLocation();
this.geoCoder = new google.maps.Geocoder();
const autocomplete = new google.maps.places.Autocomplete(this.searchElementRef.nativeElement);
autocomplete.addListener('place_changed', () => {
this.ngZone.run(() => {
// get the place result
const place: google.maps.places.PlaceResult = autocomplete.getPlace();
// verify result
if (place.geometry === undefined || place.geometry === null) {
return;
}
// set latitude, longitude and zoom
this.latitude = place.geometry.location.lat();
this.longitude = place.geometry.location.lng();
this.changeMapZoom(18); -------------> here i pass zoom level value
});
});
});
I hope it helps someone. B'cos after a full day finding and search I got the solution.
Place change, search location in AGM map. reset zoom dynamically.