【发布时间】:2019-05-09 20:08:04
【问题描述】:
更新:元素检查器下 Google 地图信息窗口中按钮上的元素如下所示:
<ion-button href="/tabs/(map:place/135)" routerdirection="forward" ion-activatable="" class="button button-solid hydrated">Details</ion-button>
但是普通页面上的按钮看起来像(里面有更多东西):
<ion-button _ngcontent-c1="" href="/tabs/(home:place/135)" routerdirection="forward" ng-reflect-router-direction="forward" ng-reflect-href="/tabs/(home:place/135)" ion-activatable="" class="button button-solid hydrated">Details</ion-button>
为什么?
我在第 34 行 (HrefDelegate.prototype.onClick) 上的 @ionic/angular/dist/directives/navigation/href-delegate.js (HrefDelegate.prototype.onClick) 中插入了一个中断,如果我在普通页面上使用一个按钮,它就会中断(完全相同)文本),但如果我在谷歌地图信息窗口中单击我的按钮,则不会。
我正在尝试从谷歌地图标记传递 routerDirection(离子)。更普遍的问题是我试图在 infoWindow 中做一些有角度的事情。用户单击标记,它会显示一个框,其中包含一个具有 routerDirection 的按钮。来自普通按钮的 routerDirection 对我有用,但不适用于 infoWindow。
当使用标记内容向前过渡时,下一页上没有返回按钮。我在下一页的离子后退按钮上没有 defaultHref,如果我这样做了,它会显示一个后退按钮,但始终使用不是本意的 defaultHref。我希望它导航回我的地图选项卡,但它似乎不知道我从哪里向前导航。
我有一个地图组件页面和一个完成大部分工作的 google-map 组件。当我创建一个标记时,我将它的内容传递给显示(有两个按钮用于测试):
const content = `
<h5>${place.name}</h5>
<p>${place.description}</p>
<ion-button href="/tabs/(map:place/135)" routerDirection="forward">Details</ion-button>
<ion-button routerDirection='forward' href='/tabs/(map:place/${place.id})'>Details</ion-button>
`;
markers.push({ lat: place.lat, lng: place.lon, title: place.name, content: content });
}
if (typeof this.map !== 'undefined') {
this.map.addMarkers(markers);
}
this.map 指的是我前面提到的 google map 组件。
@ViewChild(GoogleMapComponent) map?: GoogleMapComponent;
在我的 google-map 组件的 addMarkers 方法中,它添加了如下内容:
const marker = new google.maps.Marker(options);
if (typeof location.content !== 'undefined') {
const infoWindow = new google.maps.InfoWindow({
content: location.content
});
marker.addListener('click', () => {
if (typeof this.infoWindow !== 'undefined') {
this.infoWindow.close();
}
infoWindow.open(this.map, marker);
this.infoWindow = infoWindow;
});
因此,当我单击标记内容中的按钮时(单击标记后),我导航但没有返回按钮。有任何想法吗?感谢您的帮助。
【问题讨论】: