获取坐标上点地图机器人 [英] Get coordinates on tapping map in android

查看:147
本文介绍了获取坐标上点地图机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做出这样的事情:我有一个mapactivity,当用户点击地图上显示该位置的坐标。我已经overrided的onclick方法,但它甚至没有叫。你知道吗?

I'm trying to make something like this: I have a mapactivity and when the user taps the map it shows the coordinates of that location. I already overrided the onclick method but it isn't even called. Any Idea?

public class MapPoint extends MapActivity implements OnClickListener {

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.mappoints);

    MapView map = (MapView)findViewById(R.id.mapview);
    map.setOnClickListener(this);
    map.setBuiltInZoomControls(true);
    map.getController().setZoom(18);
    map.getController().setCenter(new GeoPoint(39735007, -8827330));


}

@Override
protected boolean isRouteDisplayed() {
    // TODO Auto-generated method stub
    return false;
}

public void onClick(View arg0) {
        Toast.makeText(this, "text", Toast.LENGTH_SHORT);
}

}

推荐答案

请尝试以下。

编写类派生的<一个href="http://$c$c.google.com/intl/de-DE/android/add-ons/google-apis/reference/com/google/android/maps/Overlay.html">Overlay类并重写<一href="http://$c$c.google.com/intl/de-DE/android/add-ons/google-apis/reference/com/google/android/maps/Overlay.html#onTap%28com.google.android.maps.GeoPoint,%20com.google.android.maps.MapView%29">onTap()方法。然后,您可以将您的覆盖到你的<一个href="http://$c$c.google.com/intl/de-DE/android/add-ons/google-apis/reference/com/google/android/maps/MapView.html">MapView. A <一个href="http://$c$c.google.com/intl/de-DE/android/add-ons/google-apis/reference/com/google/android/maps/GeoPoint.html">GeoPoint对象,从而重新presents你的位置,挖掘,传递给和Ontap()方法时,标签的地方在地图上。

Write a class which derives from the Overlay class and override the onTap() method. Then you can add your overlay to the your MapView. A GeoPoint object, which represents the position of you tap, is passed to the onTap() method when you tab somewhere on the map.

这篇关于获取坐标上点地图机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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