angulargoogle-mapsmapsangular-google-maps

Angular Google Maps zoom is working just once then you can not change zoom value


I am working on a project which is used agm. Everything is fine apart from zoom issue. I put a lot of marker on the map and when I clicked one of them I want to to zoom it's latitude and longitude. I can center this markers latitude and longitude but zoom is just working once not second time. Is there anyone help me about it. Btw I am new on Angular.

Thanks.


Solution

  • cityInfo(i){
                this.latitude=this.parkandFlyCenter[i].lat;
                this.longitude=this.parkandFlyCenter[i].lon;
                // this is not working--> this.mapZoom=14;
                //But this is working(interesting !)
                this.mapZoom= this.mapZoom+0.5;
            
          }
    <agm-map class="agm-map" 
        [latitude]="latitude" 
        [longitude]="longitude"
        minZoom="3" 
        [zoom]="mapZoom"
        [styles]="styles"
        [mapTypeControl]="true" 
        [mapTypeControlOptions]="mapType"
        (centerChange)="centerChange($event)"
        (zoomChange)="zoomChange($event)"
        (boundsChange)="boundsChange($event)"
        >
            <agm-marker-cluster [styles]="clusterStyles">
            <agm-marker *ngFor="let city of Cities; let i = index"
            [latitude]="city.lat"
            [longitude]="city.lon"
            [iconUrl]="icon"
            [label]="{color: 'white', text: sometext}"
            (markerClick)="cityInfo(i)">
    
            </agm-marker>
          </agm-marker-cluster> 
          </agm-map>

    This was my solution(to be honest not a solution but someone can have the same issue and this can be a reference)