HI я использую 2 нажмите в U см.
/**
* This Activity called when draw a fence on to the map.
*
* @author ketan kalariya(ketan.kalariya@indianic.com)
* **/
public class AddFenceActivity extends FragmentMapActivity implements
SimpleGestureListener {
private List<Overlay> mapOverlays;
double[] location = new double[2];
protected void onCreate(Bundle icicle) {
setTheme(THEME);
super.onCreate(icicle);
setContentView(R.layout.addfenceactivity);
mapView = (MapView) findViewById(R.id.addfenceactivity_mapview);
Log.d(TAG, "AddFence Activity come from Home Activity");
id = getIntent().getIntExtra("ID", 0);
/**
* Access the overlay list. Returns: The list of overlays.
**/
mapOverlays = mapView.getOverlays();
myPrefs = getPreferences(MODE_PRIVATE);
mDetector = new SimpleGestureFilter(this, this);
MapController mapController = mapView.getController();
mapView.setSatellite(false);
mapView.setBuiltInZoomControls(true);
Dataset = (GeoFencApplicationDataset) getApplicationContext();
dbHelper = Dataset.getDbHelper();
dbHelper.deleteTempTable();
}
/**
* Destroy all fragments and loaders.
*
* **/
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
}
/**
* when it called.. The fence which is drawn on to map, it will be clear and
* lat/long stored in to preference and database table will become
* empty/null
**/
private void MapClear() {
mapOverlays.clear();
prefEdit = myPrefs.edit();
prefEdit.putString("lat", "");
prefEdit.putString("long", "");
prefEdit.putString("srclat", "");
prefEdit.putString("srclong", "");
prefEdit.commit();
mapView.invalidate();
dbHelper.deleteTempTable();
drawFlag = false;
}
/**
* For accounting purposes, the server needs to know whether or not you are
* currently displaying any kind of route information, such as a set of
* driving directions.
*
* @return True if route information is displayed; false otherwise.
**/
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
/**
* Called to process touch screen events. using mDetector object of
* SimpleGestureFilter call onTouchEvent
*
* @param mMotionEvent
* The touch screen event.
* @return boolean Return true if this event was consumed.
**/
public boolean dispatchTouchEvent(MotionEvent mMotionEvent) {
this.mDetector.onTouchEvent(mMotionEvent);
return super.dispatchTouchEvent(mMotionEvent);
}
/**
* when double click on to screen put first pin on map, consider first
* geoPoint. on second double click put second pin on map and draw path on
* map mapOvelay from fist point to second and insert all lat,long in
* database
* **/
public void onDoubleTap(MotionEvent event) {
// TODO Auto-generated method stub
GeoPoint geoPoint = mapView.getProjection().fromPixels(
(int) event.getX(), (int) event.getY() - 120);
srcLat = geoPoint.getLatitudeE6() / 1E6;
srcLong = geoPoint.getLongitudeE6() / 1E6;
Drawable marker = getApplicationContext().getResources().getDrawable(
R.drawable.pin1);
mapView.getController().animateTo(geoPoint);
MapAddressOverlay itemizedOverlay = new MapAddressOverlay(marker);
itemizedOverlay.addOverlay(AddFenceActivity.this, srcLat, srcLong);
mapView.getOverlays().add(itemizedOverlay);
mapView.invalidate();
if (!String.valueOf(srcLat).equals("")
|| !String.valueOf(srcLong).equals("")) {
......
..
.
..
}