0

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?

Paul Richter
  • 10,908
  • 10
  • 52
  • 85

2 Answers2

3

JaakL is correct, remove is the correct method to call. detachFromLayer/detachFromDataSource are internal methods and should not be called by application (they are reserved for custom layers/data sources). The issue you reported is actually a bug that is already fixed in the development snapshot and will be in 2.3.1 release (it is not in 2.3.1RC1 though). Thanks for pointing it out!

MarkT
  • 301
  • 2
  • 2
2

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

JaakL
  • 4,107
  • 5
  • 24
  • 37
  • Understood. Does the same go for the `detachFromDataSource` method? I encountered that method after posting the question, and I noticed that, as an example, if I remove a marker, then add it back to the same layer, an exception is thrown indicating the element already exists in the layer's data source. I suppose what I'm curious about is (with both this and the original question) whether there is a potential for a sort-of memory leak if the internal data source is keeping a reference to the vector element (marker in this case). Thoughts? – Paul Richter Feb 19 '14 at 16:08
  • Thanks for noting - it turned out that exception on adding removed marker back was a bug in 2.3.0 release. Please check with latest snapshot where it should be fixed: https://repository-nutiteq.forge.cloudbees.com/snapshot/com/nutiteq/nutiteq-3d-sdk/snapshot/nutiteq-3d-sdk-snapshot.jar – JaakL Feb 21 '14 at 06:22
  • Ah ha, good to know. Thanks for that, I will check out the snapshot. – Paul Richter Feb 21 '14 at 15:07