Event by clicking on a Google Maps marker

Asked

Viewed 173 times

3

I wonder if there is a way to put event in Google Maps markers to open a custom information window, such as a Fragment, for example.

1 answer

4

Use the method setOnMarkerClickListener(), from the map, to "set" a Onmarkerclicklistener who will have his methodonMarkerClick() called when the user clicks on it.

GoogleMap googleMap;
googleMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
    @Override
    public boolean onMarkerClick(Marker marker) {

    }

The object received in the parameter marker is that of Marker clicked.

Behold Marker click Events in the documentation.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.