I want to make that when click in MyLocation-Button show a Toast. I try this code:
public void setMyLocationLayerEnabled(View v) {
Toast toast = Toast.makeText(getApplicationContext(), "Example de Message for Android", Toast.LENGTH_SHORT);
toast.show();
}
But no work. I hope somebody of you can help me!
map.setOnMyLocationButtonClickListener(new OnMyLocationButtonClickListener() {
@Override
public boolean onMyLocationButtonClick() {
Toast.makeText(
getActivity(),
"Example de Message for Android",
Toast.LENGTH_SHORT).show();
return true;
}
});
To get the current location after clicking MyLocationButton, then use
`googleMap.getMyLocation(); //Deprecated, So use `googleMap.setMyLocationEnabled(true); //Which allows to deal with current location`
inside setOnMyLocationButtonClickListener.
Reference link: https://www.androidtutorialpoint.com/intermediate/android-map-app-showing-current-location-android/
Hope it helps ! And thanks to Cabezas.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With