Hi, I've created a map that allow user to click on the map and draw a polyline or polygon. I placed a button to help user undo the last click and draw the polygon again, but removeOverlay doesn't work properly, the old polygon still remains on the map. Here is my link to the map
http://travelrise.com/test/prototype.html Here is my code to redraw the polygon function PolygonManager(gmap,options) { var map = gmap; var gPolygon = null; //store reference to the GPolygon var defaults = { lineColor:"#000", lineWeight:2, opacity:0.5, fillColor:"#0f0" }; var opt = options; this.update = function(subject) { var settings = $.extend(defaults,opt); var points = []; points = subject.getClickPoints();// receive the GLatLng array if (gPolygon) { map.removeOverlay(gPolygon); } if (points.length > 2) { points.push(new GLatLng(points[0].lat(),points[0].lng ())); gPolygon = new GPolygon( points, settings.lineColor, settings.lineWeight, settings.opacity, settings.fillColor, settings.opacity ); map.addOverlay(gPolygon); } } } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Maps-API?hl=en -~----------~----~----~----~------~----~------~--~---
