The overlay that appears when a marker is clicked, is created and destroyed on-the-spot implicitly. You can't manually show that (yet).
If you must have this functionality, you can create an overlay over your map with 2 ImageViews
, and call appropriate intents when they're clicked:
// Directions
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(
"http://maps.google.com/maps?saddr=51.5, 0.125&daddr=51.5, 0.15"));
startActivity(intent);
// Default google map
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(
"http://maps.google.com/maps?q=loc:51.5, 0.125"));
startActivity(intent);
Note: you need to change the coordinates based on Marker's getPosition()
and the user's location.
Now to hide the default overlay, all you need to do is return true in the OnMarkerClickListener
. Although you'll lose the ability to show InfoWindows
and center camera on the marker, you can imitate that simply enough:
mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker) {
marker.showInfoWindow();
mMap.animateCamera(CameraUpdateFactory.newLatLng(marker.getPosition()));
return true;
}
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…