8

I am using the Google Maps API v2 and am trying to embed a reference ID to a marker info window. When a user clicks on the info window, it should pass the reference ID to a new intent.

I don't actually want the reference ID to be visible to the user. I added the reference ID as a snippet and use marker.getSnippet() to get the reference ID to pass to the new activity. Is there a way to hide the snippet so the user doesn't see it?

2 Answers 2

8

Customize the info window contents via an InfoWindowAdapter, attached it to your GoogleMap via setInfoWindowAdapter(). Implement onInfoContents() on the adapter to return something that does not contain your snippet.

1
1

I've been looking for the same thing and found something interesting myself. The trick might seem so dumb but it worked perfect. After getting the value from the Snippet in onMarkerClick(Marker m) I'm setting it back to null :D Here is the code:

@Override
public boolean onMarkerClick(Marker marker) {
    locationMarker = marker;
    Intent intent = new Intent(getApplicationContext(),MarkerInfoView.class);
    String uid = marker.getSnippet();
    marker.setSnippet("");
    intent.putExtra(UID,uid);
    startActivity(intent);
    return false;
}

So, on onClick() it shows the title and opens another activity and shows the related other information of the user there. Give me crazy thumbzzup if it works for you ;) Let me know if anyone need other coding help on tracking user and marker click operations.I'll try yo help as much as possible. Good Luck (y)

Screenshot here: enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.