我正在使用这个谷歌地图角度组件教程,它工作得很好!但是打开信息窗口会引发异常。
这是我的代码,它在 npm 包中的“MapInfoWindow”组件上调用“this.infoWindow.open”方法。
import {
MapInfoWindow,
MapMarker,
GoogleMap
} from '@angular/google-maps';
export class YogabandEventsComponent implements OnInit {
@ViewChild(MapInfoWindow, {
static: false
}) infoWindow: MapInfoWindow;
@ViewChild(GoogleMap, {
static: false
}) googleMap: GoogleMap;
openInfo(marker: MapMarker, content) {
this.infoContent = content;
this.infoWindow.open(marker);
}
}
<google-map [options]="options" [zoom]="zoom" [center]="center" class="h-100" height="100%" width="100%">
<map-marker #markerElem *ngFor="let marker of markers" (mapClick)="openInfo(markerElem, marker.info)" [position]="marker.position" [label]="marker.label" [title]="marker.title" [options]="marker.options">
</map-marker>
<map-info-window>{{ infoContent }}</map-info-window>
</google-map>
什么时候
infoWindow.open(标记)
被称为它进入
google-maps.js // 第 1122 行
但在第 1122 行收到错误,因为没有“getAnchor()”方法
this.infoWindow.open(this._googleMap.googleMap, anchor ? anchor.getAnchor() : undefined);
// in google-maps.js
open(anchor) {
this._assertInitialized();
this._elementRef.nativeElement.style.display = '';
this.infoWindow.open(this._googleMap.googleMap, anchor ? anchor.getAnchor() : undefined); // line 1122
}
繁星淼淼
holdtom
随时随地看视频慕课网APP
相关分类