[Fixed] Is there any way to fit agm-polyline inside map in angular 7


I want to fit the polylines inside my map and want to set the zoom level dynamically according to polylines size and location of the polylines
My code is here:

  <agm-map style="height: 500px" [latitude]='selectedLatitude' [longitude]='selectedLongitude'
    <agm-polyline *ngFor='let polyline of xPolyline' [strokeColor]="'#0000ff'" [strokeOpacity]="0.9">
      <agm-polyline-point *ngFor="let point of polyline;let i = index;" [latitude]="point.latitude"


<agm-map ... [fitBounds]="true"></agm-map>

<agm-polyline-point ... [agmFitBounds]="true"></agm-polyline-point>

No further calculations or extra calls are necessary. AGM is going to calculate this for you on the fly.

Leave a Reply

(*) Required, Your email will not be published