I am hitting a problem trying to open the infoWindow in an @angular/google-maps control (part of angular/components).
I have followed a tutorial as a first time user of this new functionality. My setup is slightly different than in the tuturial. I want to set just one marker and one infoWindow - rather than an array of markers.
I have setup a google-map control like this:
<google-map height="500px" width="100%" [zoom]="zoom" [center]="marker.position" [options]="options">
<map-marker #markerElement [position]="marker.position" (mapClick)="openInfo(markerElement)">
<map-info-window>MyContent</map-info-window>
</map-marker>
<!-- <map-info-window>MyContent</map-info-window> -->
</google-map>
(You can see from the commented out code in the above, that I have tried the placing of the infoWindow inside and outside the marker. Neither has solved the problem and I do not know which is best...)
And here is the relevant component Typescript:
@ViewChild(MapInfoWindow, { static: false }) infoWindow: MapInfoWindow
marker;
zoom = 8;
options: google.maps.MapOptions = {
mapTypeId: 'terrain'
}
openInfo(marker: MapMarker) {
console.log(marker);
console.log(marker.position);
this.infoWindow.open(marker);
}
addMarker() {
this.marker = ({
position: {
lat: this.observation.locationLatitude,
lng: this.observation.locationLongitude
},
label: {
color: 'red',
text: 'Marker label',
},
title: 'Marker title',
options: { animation: google.maps.Animation.BOUNCE },
})
}
The openInfo(marker: MapMarker) method is the most relevant bit, I think.
The (mapClick)="openInfo(markerElement)" event is correctly sent from the map control. It logs in the console the 'marker' object. However, it raises an error rather than opening the infoWindow.
The error is:
The error ('anchor.getAnchor is not a function') is raised on the this.infoWindow.open(marker); method. I have also tried it without an argument like this: this.infoWindow.open();.
The API documentation is here, and I have attached a screenshot of the relevant section:
I just cannot workout how to get it to work. I might be missing the woods from the trees, but can anyone point me in the right direction?

