title: Reference a marker from outside AGM Google Map
body: <p>I'm using <a href="https://angular-maps.com/" rel="nofollow noreferrer">AGM Google Map</a> component. I added marker in template with <code>*ngFor</code>.</p>
  
  <pre><code>import {  Component,  NgModule} from '@angular/core';
  import {  BrowserModule} from '@angular/platform-browser';
  import {  AgmCoreModule} from '@agm/core';
  import {  AgmJsMarkerClustererModule,  ClusterManager } from '@agm/js-marker-clusterer;
  
  @Component({
    selector: 'my-app',
    styles: [`
      .agm-map-container {
         height: 300px;
       }
    `],
    template: `
     &lt;agm-map #gm style="height: 300px" [latitude]="52.692868" [longitude]="7.834982"&gt;
  
      &lt;agm-marker *ngFor="let m of markers; let i = index" (mouseOver)="onMouseOver(infoWindow,gm)" [latitude]="m.latitude" [longitude]="m.longitude"&gt;
  
              &lt;agm-info-window [disableAutoPan]="false" #infoWindow&gt;
                 Test
              &lt;/agm-info-window&gt;
  
  
      &lt;/agm-marker&gt;
  
  &lt;/agm-map&gt;
  &lt;button type="button" (click)="onFocusMarker1($event)"&gt;Focus marker 1&lt;/button&gt;
  &lt;button type="button" (click)="onFocusMarker2($event)"&gt;Focus marker 2&lt;/button&gt;
  
  `})
  export class AppComponent {
  
    markers: Array&lt;any&gt;
    constructor(){
  
      this.markers=[{latitude:52.692868, longitude:7.834982},{latitude:52.992868, longitude:7.034982}]
  
    }
  
    onFocusMarker1(event){
      event.preventDefault();
  
      alert("How to take reference of first marker, centrer the map on it and open the info window?");
    }
  
    onFocusMarker2(event){
      event.preventDefault();
  
      alert("How to take reference of second marker, centrer the map on it and open the info window?");
    }
  
     onMouseOver(infoWindow, gm) {
  
          if (gm.lastOpen != null) {
              gm.lastOpen.close();
          }
  
          gm.lastOpen = infoWindow;
  
          infoWindow.open();
      }
  }
  </code></pre>
  
  <p>Now I need to press a button outside the map and center the map on a marker and open its <code>InfoWindow</code> but I cannot find a method to take the marker reference to achieve this.</p>
  
  <p>I create a Plunkr <a href="https://embed.plnkr.co/zxd41ceSSi8l07v3P4Kt/" rel="nofollow noreferrer">here</a></p>