code: function() {
  
          //remove the popup from the map
          if ((this.layer != null) && (this.layer.map != null)) {
              if (this.popup != null) {
                  this.layer.map.removePopup(this.popup);
              }
          }
          // remove the marker from the layer
          if (this.layer != null && this.marker != null) {
              this.layer.removeMarker(this.marker);
          }
  
          this.layer = null;
          this.id = null;
          this.lonlat = null;
          this.data = null;
          if (this.marker != null) {
              this.destroyMarker(this.marker);
              this.marker = null;
          }
          if (this.popup != null) {
              this.destroyPopup(this.popup);
              this.popup = null;
          }
      }
docs: Method: destroy
  nullify references to prevent circular references and memory leaks