Search code examples
androidgoogle-maps-markersgoogle-maps-api-2

imMarkerClick Android Google Maps API v2 intent to another activity


I am currently developing a map application on android. I was wondering if marker can act as a button. Like for example if i can create an intent and do to another activity when marker is clicked.

For example:

public boolean onMarkerClick(final Marker marker) {

            if (marker.equals(startPerc)) 
            {
                Intent intent = new Intent(this, SpecificRoom.class);
                String bn = startPerc.getSnippet();
                intent.putExtra(EXTRA_MESSAGE, bn);
                startActivity(intent);
            }
            return false;
        }

The code does not show any errors but it does nothing when marker is clicked. I am not even sure if markers provide that kind of functionality. Any ideas? Thanks.


Solution

  • As there is onMarkerClick() you can use, there is no reason you could not send any intents, you can do whatever you'd do in any other function of yours. Just remove the if statement to be sure the inner body gets called, and you are good to go.