question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

marker.android.remove is not a function

See original GitHub issue

When trying to remove a marker from the map on Android, I get the error: marker.android.remove is not a function

It works fine on iOS. I notice that the iOS code just calls marker.ios.map = null in the removeMarker function. But the Android code invokes the method remove on the marker, marker.android.remove()

marker.android is an instance of com.google.android.gms.maps.model.MarkerOptions which doesn’t expose a remove() method. remove is a method of com.google.android.gms.maps.model.Marker

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:3
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
tylerablakecommented, Mar 22, 2019

Yes, that’s how I’m adding them. It’s adding the marker fine, removing markers doesn’t work on Android.

1reaction
dimitriospafoscommented, Jun 15, 2020

@tylerablake looks like it works. I was having a different issue when I was trying to re-add a marker after removing all of the markers from the map and I thought it could be failing because of the issue mentioned above. Something like:

var marker = this.mapView.findMarker(m => m.infoWindowTemplate === "myInfoTemplateName");
this.mapView.removeAllMarkers();
this.mapView.addMarker(marker);

The above fails on “addMarker” in Android but works for IOS. I just created a new marker instead of reusing the same one and it seems like it works now.

Thanks for taking the time to look into it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

android marker remove() method not working - Stack Overflow
First check that if your arraylist contains data and if it is then check if(marker!=null){ marker.remove(); . when you add new marker. –...
Read more >
Removing Markers | Maps JavaScript API - Google Developers
This example creates a map where each click by the user creates a marker. Click the buttons to hide or delete all of...
Read more >
javascript - Leaflet: How to add a marker to, or remove it from ...
Try something like this. Put the marker to a variable, and when creating a new one, it the variable already has a value...
Read more >
Managing delete markers - Amazon Simple Storage Service
If you use a DeleteObject request where the current version is a delete marker (without specifying the version ID of the delete marker),...
Read more >
Removing Old Markers - YouTube
Link to the playlist: https://goo.gl/pfGNnwRemoving markers from a google map.➤Google Maps and Directions Playlist:↻ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found