点击谷歌地图div上的按钮上的事件?

时间:2017-08-23 12:29:19

标签: google-maps cordova ionic2 cordova-plugins ionic3

我正在尝试在原生的cordova google maps div上放置一个html按钮。

问题是地图图层正在连续请求焦点。

如果我使用“setClickable(false)”事件,按钮可以正常工作,但地图不可用。

有什么办法吗?

1 个答案:

答案 0 :(得分:2)

将按钮放在地图所在的div的里面,如下所示:

<ion-header>
    <ion-navbar color="primary">
        <ion-title>Map Demo</ion-title>
    </ion-navbar>
</ion-header>
<ion-content>
    <div #map id="map" style="height:100%;">
        <div class="action-buttons">
            <button color="primary" ion-button text-only>
                Button 1
            </button>
             <button color="primary" ion-button text-only>
                Button 2
            </button>
        </div>
    </div>
</ion-content>

然后通过设置容器的位置将它们放在您想要的位置,为absolute值:

.action-buttons {
    display: block;
    width: calc(100% - 16px);
    position: absolute;
    top: 16px;
    right: 16px;
    text-align: right;
    z-index: 999;

    button {
        display: inline-block;
        margin: 4px;
    }
}