// We define the function first function UndeployControl(hotelMarker, point) { this.hotelMarker = hotelMarker; var defaultHotelIcon = new GIcon(); defaultHotelIcon.image = "images/transparent.png"; defaultHotelIcon.iconSize = new GSize(20, 20); defaultHotelIcon.iconAnchor = new GPoint(10, 10); var opts = {}; opts.icon = defaultHotelIcon; GMarker.call(this, point, opts); } // To "subclass" the GControl, we set the prototype object to // an instance of the GControl object UndeployControl.prototype = new GMarker(new GLatLng(0,0)); // Creates a one DIV for each of the buttons and places them in a container // DIV which is returned as our control element. We add the control to // to the map container and return the element for the map class to // position properly. UndeployControl.prototype.initialize = function(map) { GMarker.prototype.initialize.call(this,map); var tmpControl = this; var tmpMarker = this.hotelMarker; GEvent.addListener(this, "click", function() { tmpMarker.undeploy(); tmpControl.remove(); map.removeOverlay(tmpControl); }); }