1
votes

I draw circles and polygons on Google maps using DrawingManager. I tried to remove a circle/polygon by using the below code.

selectedShape.setMap(null); 

Here selectedShape is either circle or polygon.

But it just hides the shape from the view. Internally that shape present in DOM. For example: I have drawn 2 circles and 2 polygons. Now the total of shapes is 4. If I remove a circle or polygon, the count is still 4. It's not removed from DOM. Just hidden.

I want to completely remove a selected shape out of many shapes.

1
Please provide a Minimal, Complete, Tested and Readable example that demonstrates the issue. - geocodezip

1 Answers

1
votes

Has you can read from the documentation:

https://developers.google.com/maps/documentation/javascript/shapes#circle_remove

The .setMap(null) does not delete the circle. It simply removes the circle from the map. If instead you wish to delete the circle, you should remove it from the map, and then set the circle itself to null.