我如何可以在Android谷歌地图触摸屏幕来获得地址信息 [英] How can I get address information by touching screen on android google map

查看:180
本文介绍了我如何可以在Android谷歌地图触摸屏幕来获得地址信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在这个网站上的所有答案,但他们没有工作。我使用Android SDK中r_18和深化发展的Adnroid内2.2的应用程序。我仍然不知道为什么例子是行不通的。

如果我加mapView.setOnTouchListener(本);到的onCreate()函数下面的工作一次。当函数返回false,它不工作了。

 公共布尔onTouch(视图V,MotionEvent事件){
    如果(event.getAction()== 1){
        GeoPoint的P = MapView.getProjection()在。fromPixels(
            (INT)event.getX(),
            (INT)event.getY());
            showToast(如果11);
            mapCon = mapView.getController();
            mapCon.animateTo(P);
            //mapCon.setZoom(mapCon.zoo);
    }
    其他
    如果(event.getAction()== 2)
    {
        showToast(如果22);
      GeoPoint的P = MapView.getProjection()在。fromPixels(
      (INT)event.getX(),
      (INT)event.getY());
      mapCon = mapView.getController();
      mapCon.animateTo(P);
    }
    其他
        如果(event.getAction()== 0)
        {
            showToast(如果00);
        }    回报(super.onTouchEvent(事件));}


解决方案

我解决了这个问题。

我是用这种方法mapView.setBuiltInZoomControls(真);

当我删除它,我开始使用触摸屏。

I tried all answers on this web site but None of them worked. I am using android sdk r_18 and developping an application on adnroid 2.2 . I still don't know why examples does not work.

if I add mapView.setOnTouchListener(this); to onCreate() function the at below works for one time. When the function returns false, it does not work again.

public boolean onTouch(View v, MotionEvent event) {     
    if (event.getAction() == 1) {                
        GeoPoint p = mapView.getProjection().fromPixels(
            (int) event.getX(),
            (int) event.getY());
            showToast("if 11");
            mapCon = mapView.getController();
            mapCon.animateTo(p);
            //mapCon.setZoom(mapCon.zoo);
    }       
    else
    if (event.getAction() == 2)
    {
        showToast("if 22");
      GeoPoint p = mapView.getProjection().fromPixels(
      (int) event.getX(),
      (int) event.getY());
      mapCon = mapView.getController();
      mapCon.animateTo(p);
    }
    else
        if (event.getAction() == 0)
        {
            showToast("if 00");
        }

    return (super.onTouchEvent(event));

}

解决方案

I solved the problem.

I was using this method "mapView.setBuiltInZoomControls(true);"

When I removed it I started to use touchscreen.

这篇关于我如何可以在Android谷歌地图触摸屏幕来获得地址信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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