Agm-Direction icon indicating copy to clipboard operation
Agm-Direction copied to clipboard

map zoom changes when agp-direction is updated

Open DanielEFGS opened this issue 5 years ago • 1 comments

i have the following code:

`<agm-map
    [latitude]="lat"
    [longitude]="lng"
    [zoom]="zoom"
    style="height: 100%; width: 100%;">

    <agm-marker *ngFor="let d of markers"
        (markerClick)="clickedMarker()"
        [latitude]="d.lat"
        [longitude]="d.lng"
        [visible]="d.visible"
        [iconUrl]="d.icon"
        [animation]="d.animation">    
    </agm-marker>

    <agm-direction
        *ngFor="let dir of current_route" 
        [origin]="dir.origin"
        [destination]="dir.destination"
        travelMode="DRIVING"
        [renderOptions]="renderOptions">
    </agm-direction>

</agm-map>`

when adding a new address the map zoom increases by itself, despite having the fixed zoom at 18. How can i avoid this problem?

DanielEFGS avatar Jan 30 '20 21:01 DanielEFGS

Hi @DanielEFGS !

See the documentation for the DirectionsRendererOptions - preserveViewport

For example:

<agm-direction
    ...
    [renderOptions]="renderOptions"
>
</agm-direction>
public renderOptions = {
    preserveViewport: true,
};

explooosion avatar Feb 07 '20 07:02 explooosion