Google Maps Android API-在地图上触发触摸事件 [英] Google Maps Android API - trigger touch event on map

查看:152
本文介绍了Google Maps Android API-在地图上触发触摸事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一种以编程方式触发/触发地图触摸事件的方法.有什么解决办法吗?

更新1:

我上面有地图和kmlLayer. kmlLayer仅具有一个click事件,但就我而言,当我单击另一个按钮时,我需要触发此事件.这正是我想要的.

根据此答案,我添加了一个伪造的以编程方式触摸的事件,但是在地图视图上无效! >

更新2:

我的问题与 Google Maps Android API v2完全不同-检测地图上的触摸.因为这是关于如何在发生真正的触摸时进行交互,但就我而言,我想首先以编程方式触发事件!之后,是地图或非专业人士的收听者.

解决方案

您可以尝试...

googleMap.setOnCameraMoveStartedListener(new GoogleMap.OnCameraMoveStartedListener() {
    @Override
    public void onCameraMoveStarted(int reason) {
        if (reason == REASON_GESTURE) {
            // The user gestured on the map.
        } else if (reason == REASON_API_ANIMATION) {
            // The user tapped something on the map.
        } else if (reason == REASON_DEVELOPER_ANIMATION) {
            // The app moved the camera.
        }
    }
});

I need a way to trigger/fire a map touch event programmatically. Is there any solution?

Update 1:

I have map and a kmlLayer on it. the kmlLayer has only a click event but in my case I need to fire this event when I click on another button. it's exactly what I want.

According to this answer I add a fake and programmatically touch event but it not worked on a map view!

Update 2:

My question is totally different with Google Maps Android API v2 - detect touch on map. Because it is about how to interact when a real touch happend but in my case I want to fire event programmaticly first! after this the map or laye listener.

解决方案

you can try this...

googleMap.setOnCameraMoveStartedListener(new GoogleMap.OnCameraMoveStartedListener() {
    @Override
    public void onCameraMoveStarted(int reason) {
        if (reason == REASON_GESTURE) {
            // The user gestured on the map.
        } else if (reason == REASON_API_ANIMATION) {
            // The user tapped something on the map.
        } else if (reason == REASON_DEVELOPER_ANIMATION) {
            // The app moved the camera.
        }
    }
});

这篇关于Google Maps Android API-在地图上触发触摸事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆