How can I get address information by touching scre

2019-08-16 19:40发布

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));

}

3条回答
劳资没心,怎么记你
2楼-- · 2019-08-16 20:15

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楼-- · 2019-08-16 20:16

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

查看更多
smile是对你的礼貌
4楼-- · 2019-08-16 20:20

I solved the problem.

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

When I removed it I started to use touchscreen.

查看更多
登录 后发表回答