I add a marker on each map click, and I only want to see the last one.
I tried the following code:
if(marker!=null)
{
marker.visible(false);
marker=null;
}
marker=new MarkerOptions().position(latLng);
googleMap.addMarker(marker);
I see every marker even though I set it to invisible.
How can I remove after each click? I can't find any remove methods.
Just keep a reference to the marker each time you do the click :
Marker marker = map.addMarker(MARKER_OPTIONS);
Then call remove()
method :
marker.remove();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With