Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

No easy way to clear polygons from the map #36

paultag opened this Issue Jun 7, 2012 · 2 comments


None yet
3 participants

paultag commented Jun 7, 2012

Whereas you may removeMarkers();, one would expect to be able to removePolygons(); :)

It'd be nice to support a clean way of removing polygons that are drawn.


npepinpe commented Jun 7, 2012

Polygons, polylines, markers, etc., all of these are special types of overlays; the cleanest way would be to refactor these functions with this hierarchy in mind, since the removing functions are basically identical but operate on different data sources. To remove a single polygon, you can simply use removeOverlay(polygon). Otherwise, here is:

this.removePolygon = function(polygon) {

this.removePolygons = function() {
    $.each(self.polygons, function(polygon) {

    self.polygons = [];

Still, not the cleanest way, since we should be doing the same for Rectangles, Circles, Polygons, Polylines, etc., anything that is a special case of Overlay.

paultag commented Jun 7, 2012

I was able to use removeOverlay, but it needed me to track the polygon object -- which isn't a problem, I was just expecting something to clear the map of polygons :)

Thanks for your quick response, @npepinpe

hpneo added a commit that referenced this issue Aug 26, 2012

Fix map events without MouseEvent object (Issue #56) / Fix bug in dra…
…wCircle and drawRectangle / Fix bug in zoomIn and zoomOut / New methods: removePolygon and removePolygons (Issue #36)

@hpneo hpneo closed this Aug 26, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment