Modification of your original code:
import { Component, Input } from '@angular/core';
@Component({
selector: 'core-map',
styleUrls: [ './map.component.scss' ],
templateUrl: './map.component.html',
})
export class MapComponent {
protected map: any;
constructor() {}
protected mapReady(map) {
this.map = map;
}
public markerClicked = (markerObj) => {
if (this.map)
this.map.setCenter({ lat: markerObj.latitude, lng: markerObj.longitude });
console.log('clicked', markerObj, { lat: markerObj.latitude, lng: markerObj.longitude });
}
}
Then add the following to agm-map
<agm-map (mapReady)="mapReady($event)"></agm-map>