Reputation: 45058
I have a MapView
in my application. I've gotten it to work as I want it to but I'd like to handle all the onClick
or an equivalent event of the MapView
and open the Google Maps application.
I've read that I can open the Google Maps application but raising an Intent
like this:
String uri = "geo:"+ latitude + "," + longitude;
startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri)));
How can I trap the aforementioned event of my MapView
? I haven't been able to figure this out. Thanks.
Upvotes: 1
Views: 1296
Reputation: 45058
I used the onTap
event like this:
public boolean onTap(GeoPoint gptLocation, MapView mapMap) {
String strCoordinates = String.format("%f,%f", gptCoordinates.getLatitudeE6() / 1E6, gptCoordinates.getLongitudeE6() / 1E6);
String strUri = String.format("geo:%s?z=14", strCoordinates);
Intent ittMap = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(strUri));
ittMap.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.ctxContext.startActivity(ittMap);
return false;
}
Upvotes: 0
Reputation: 3689
You should have a class that extends com.google.android.maps.Overlay
in your activity and use this class' onTouchEvent()
method. Like this:
class MyOverlay extends Overlay {
@Override
public boolean onTouchEvent(MotionEvent e, MapView mapView) {
....
}
....
}
Upvotes: 1