谷歌地图街景不能与angular 6配合使用,我称之为倍数
我提供了一个功能,可以在某个位置打开谷歌街景。当我点击一个按钮时,它会显示,当我再次点击它时,它会隐藏。这是一个模式引导弹出窗口 当我第一次点击按钮显示它时,它工作正常。但当我关闭模式弹出窗口并再次打开它(或在任何其他位置弹出窗口)时,它显示的街景是错误的。有一个大的缩放,没有地图的底部来缩放和移动 第一次打开街景时: 关闭并打开街景中的相同或其他位置后: 我的html代码是:谷歌地图街景不能与angular 6配合使用,我称之为倍数,angular,google-maps,google-maps-api-3,google-street-view,Angular,Google Maps,Google Maps Api 3,Google Street View,我提供了一个功能,可以在某个位置打开谷歌街景。当我点击一个按钮时,它会显示,当我再次点击它时,它会隐藏。这是一个模式引导弹出窗口 当我第一次点击按钮显示它时,它工作正常。但当我关闭模式弹出窗口并再次打开它(或在任何其他位置弹出窗口)时,它显示的街景是错误的。有一个大的缩放,没有地图的底部来缩放和移动 第一次打开街景时: 关闭并打开街景中的相同或其他位置后: 我的html代码是: [...] <button type="button" class="btn
[...]
<button type="button" class="btn btn-simple-dark" (click)="initialize()" [attr.aria-expanded]="!isCollapsed" aria-controls="collapse">
{{ isCollapsed ? 'Mostrar' : 'Ocultar' }} Street View
</button>
<div [ngClass]="{streetView: !isCollapsed}" id="street-view"></div>
[...]
有人能帮我吗
注意。嘿,可能是您没有再次将this.flag变量设置为false吗?不,如果您多次单击“显示/隐藏”按钮,flag变量仅用于防止多次重新加载街景组件。在任何情况下,我都试图删除带有标志变量的if语句,但它不起作用
[... The imports...]
export class ModalMupiComponent extends ModalComponent {
isCollapsed = true;
flag = false;
constructor(public activeModal: NgbActiveModal) {
super(activeModal);
}
initialize() {
if (this.flag) {
this.isCollapsed = !this.isCollapsed;
} else {
const panorama = new google.maps.StreetViewPanorama(
document.getElementById('street-view'),
{
position: {lat: this.obj.lat, lng: this.obj.lon},
pov: {heading: 165, pitch: 0},
zoom: 1,
});
this.isCollapsed = !this.isCollapsed;
this.flag = true;
}
}
}