Search code examples
javaandroidnutiteq

Proper way to remove a marker from Nutiteq map


As is similar to many other mapping APIs, the nutiteq map api contains a MarkerLayer that can be added to the map. It has a simple method for removing markers (for example: markerLayer.remove(myMarker)).

I noticed that the Marker class inherits a method called detachFromLayer, which originates in the VectorElement from which Marker extends. According to the Javadoc:

This method is intended for vector layers. When element is removed from layer, it must be detached to drop the element-layer link.

Question: Since a Marker is a VectorElement, and a MarkerLayer is a VectorLayer, given the above Javadoc description, what is the proper way to remove a marker from the marker layer?

Would I be correct that the proper way is to both remove the marker from the layer (using MarkerLayer#remove), and to invoke detachFromLayer? Or is it sufficient to merely remove the marker from the layer?


Solution

  • Use markerLayer.remove(myMarker) , detachFromLayer is an internal method and you should not use it normally.