thomas2k2k thomas2k2k - 1 year ago 72
Java Question

Removing last added Marker with number on .title

I immediately want to point out that I know such methods as setVisible () and remove (), but I do not know how to use them in this particular case. Well, in my application I add markers on the map in different places, which are numbered .titles and would like to make a button that will remove the last added marker.
Each successive marker in my application has a feature .title (String.valueOf (f)), where f is the numbers that represent another marker from 0.
I might add that the markers are assigned to each collected location saved in the ArrayList.

How will look button, which when pressed will remove the last marker from the map? Only last.

Answer Source

hold pointers to them then you will be able to remove them, here is sample:

// Somewhere above:
private Marker mMyLocationMarker;

// Add marker with options
mMyLocationMarker = mGoogleMap.addMarker(options);

// And to remove:

need more markers? - hold pointers in List, etc..

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download