I'm using here.com javascript api v3. I'm using the following line to reset the map (by removing all objects in it):
map.removeObjects(map.getObjects());
This function runs with no problem when initializing (map is empty). But when I trigger the reset (via a button), and the map has objects in it, I get the error mentioned in title. I tried displaying the "map.getObjects()" function in the console, and it shows the objects it carries with no complications.
How can I find out what the problem is? How can I know which object javascript is talking about when saying "Object not found"?
The error is not in the line pointed by the console when the error occurs. This happened because the map had added a Group object, which contained some elements that were already in the map. When the map started removing objects, the objects already removed by the map were the same elements that belonged to the group object. Thus, when the map started removing the group object, its contents could not be found.