How can I get address information by touching screen on android google map

♀尐吖头ヾ 提交于 2019-12-11 18:40:48

问题


I tried all answers on this web site but None of them worked. I am using android SDK r_18 and developing an application on android 2.2. I still don't know why examples do 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));

}

回答1:


Well as there isnt enough information in your question on what you have already working and what you have left to do, and what languages you are exactly using i will put this up till you put this information in your question.

I recently created an android application with google maps as part of it and used this article to get the google maps working so i can tell you that this works so if you are using Javascript in your application have a look at this article, it should help you




回答2:


TO get address you must be using GeoCoder. Now there is some error in other API of android when you use GeoCoder.

Use 2.1 to test stuff with GeoCoder




回答3:


I solved the problem.

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

When I removed it I started to use touchscreen.



来源:https://stackoverflow.com/questions/10580770/how-can-i-get-address-information-by-touching-screen-on-android-google-map

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!