I am creating a Circle using the google.maps.Circle() method. This all works fine and dandy, but how can I remove said circle?
My code:
var populationOptionsAgain = { strokeColor: "#c4c4c4", strokeOpacity: 0.35, strokeWeight: 0, fillColor: "#ffffff", fillOpacity: 0.35, map: map, center: results[0].geometry.location, radius: 40000 }; cityCircle = new google.maps.Circle(populationOptionsAgain);
We found two handy tools that you can use to draw a radius on your map. One is CalcMaps, and the other one is Maps.ie. If you're using CalcMaps, click on Draw a circle and add the circle on the map area you're interested in. Use can then use the drop-down menu to select the radius type you want to use.
You need to call the setMap method on the Circle object to null:
cityCircle.setMap(null);
To remove a circle from the map, call the setMap()
method passing null
as the argument.
circle.setMap(null);
Note that the above method 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
.
https://developers.google.com/maps/documentation/javascript/shapes#circle_remove
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With