Detect touch on MapView, onTap(GeoPoint p, MapView mapView)

Last post discussed how to Detect touch on marker in MapView. Alternatively, we can override the callback method onTap(GeoPoint p, MapView mapView) of ItemizedOverlay to detect touch on MapView in any position. The callback method passed with two parameter, The first parameter, geoPoint p, is the corsponding coordinate of the point of touch.

example:

Detect touch on MapView, onTap(GeoPoint p, MapView mapView), to add marker.

Modify from last post, Detect touch on marker in MapView. Override the method onTap(GeoPoint p, MapView mapView) to add marker on the map.

 @Override
public boolean onTap(GeoPoint p, MapView mapView) {
// TODO Auto-generated method stub

String title = "pt:" + String.valueOf(overlayItemList.size() + 1);
String snippet = "geo:\n"
+ String.valueOf(p.getLatitudeE6()) + "\n"
+ String.valueOf(p.getLongitudeE6());

addItem(p, title, snippet);

return true;
}


next:
- Handle both onTap(GeoPoint p, MapView mapView) and onTap(int index) implemented in MapView

0 Response to "Detect touch on MapView, onTap(GeoPoint p, MapView mapView)"

Posting Komentar