0

我有一个 MapActivity,并且使用 ItemizedOverlay 显示地图图钉。我想将 onTap 事件转移到 MapActivity。(onTap 函数存在于 ItemizedOverlay 类中)。如何做到这一点?

4

1 回答 1

0
class CurOverlay extends Overlay
 {
   private GeoPoint pointToDraw;
    String addstr,addcity;
   @Override
    public boolean onTap(GeoPoint p, MapView mapView) {
        // TODO Auto-generated method stub

      final double taplat,taplon;
        taplat=p.getLatitudeE6()/1E6;
       taplon=p.getLongitudeE6()/1E6;



            Geocoder geo = new Geocoder(getApplicationContext(), Locale.getDefault());
            List<Address> add;
            try
            {

                add = geo.getFromLocation(taplat,taplon,1);

                Log.i("ADD OBJ SIZE IS----",""+add.size());
                if (add.size() > 0) 
                {

                    addstr = add.get(0).getAddressLine(0)+" "+add.get(0).getAddressLine(1);
                }
}
catch (IOException e) 
            {

                e.printStackTrace();
            }

        return super.onTap(p, mapView);
    }
 public void setPointToDraw(GeoPoint point) {
     pointToDraw = point;
   }


   public GeoPoint getPointToDraw() {
     return pointToDraw;
   }
}

Just add this code to your tapactivity and call it from other activity (by ActivityforResult) and get the location there simple....

于 2011-08-11T07:01:59.870 回答