Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

My location button event listener

Tags:

I enabled the my-location layer of the Google Maps Android API v2, which adds the floating button to go to the user's current location. I need a way to detect a click on this button. Is this possible?

like image 746
Juliano Nunes Silva Oliveira Avatar asked Feb 08 '13 17:02

Juliano Nunes Silva Oliveira


1 Answers

Since this question was posted, Google has updated the API. They have added an onMyLocationButtonClick() listener.

To add the listener:

//add location button click listener
map.setOnMyLocationButtonClickListener(new GoogleMap.OnMyLocationButtonClickListener(){
    @Override
    public boolean onMyLocationButtonClick()
    {
        //TODO: Any custom actions
        return false;
    }
});

Returning false will essentially call the super method. Returning true will not.

like image 122
CyberEd Avatar answered Sep 20 '22 08:09

CyberEd