获取坐标上点地图机器人标上、机器人、地图

2023-09-12 07:36:08 作者:何以情深

我试图做出这样的事情:我有一个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);
}

}

推荐答案

请尝试以下。

编写类派生的Overlay类并重写onTap()方法。然后,您可以将您的覆盖到你的MapView. A 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.