I want to make it so that when a user creates a marker in google maps, it is able to be double clicked (or held on or something) and bring up a new Activity. Right now I have it so that I create a marker on the map manually and use an onMarkerClickListener
to wait until the marker is clicked to launch the new activity. Basically, I want to make it so that all markers created inside my app share this behavior, and I need some sort of check to differentiate between my own user marker and Google/external Markers.
Here is the code below:
public void setUsermarker() {
mMap.setOnMarkerClickListener(new OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker) {
if (marker.equals(userMarker)) { //if clicked marker equals marker created by user
Intent intent = new Intent(MapsActivity.this, ObjectViewActivity.class);
startActivity(intent);
} //Otherwise just show the info window
return false;
}
});
}
You can add the ID of each Marker that you explicitly add to your map in a
Set<String>
in order to differentiate them from the other Markers on your map.Documentation: https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#getId()
When adding a Marker in your app, capture the returned Marker, get the ID, and add the ID to the Set:
Then, just check if the Marker ID is in the Set before launching the other Activity: