explooosion / Agm-Direction

This is the directive for @agm/core (not official)
https://robby570.tw/Agm-Direction-Docs/
MIT License
75 stars 26 forks source link

map zoom changes when agp-direction is updated #88

Open DanielEFGS opened 4 years ago

DanielEFGS commented 4 years ago

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?

explooosion commented 4 years ago

Hi @DanielEFGS !

See the documentation for the DirectionsRendererOptions - preserveViewport

For example:

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