我正在使用這個(gè)谷歌地圖角度組件教程,它工作得很好!但是打開(kāi)信息窗口會(huì)引發(fā)異常。這是我的代碼,它在 npm 包中的“MapInfoWindow”組件上調(diào)用“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>什么時(shí)候infoWindow.open(標(biāo)記)被稱為它進(jìn)入google-maps.js // 第 1122 行但在第 1122 行收到錯(cuò)誤,因?yàn)闆](méi)有“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}
谷歌地圖 Angular9 打開(kāi)信息窗口時(shí)出錯(cuò),找不到 getAnchor()
繁星淼淼
2022-11-11 15:03:57