function ResultsOverlay(opt_options) {
  // Initialization
  this.setValues(opt_options);
  this.markers = $A();
  this.polylines = $A();
  this.listeners_ = [];
};

ResultsOverlay.prototype = new google.maps.OverlayView;

  // Implement onAdd
ResultsOverlay.prototype.onAdd = function() {
 // Ensures the label is redrawn if the text or position is changed.
  this.listeners_ = [
  ];

};

ResultsOverlay.prototype.addMarker = function(marker) {
  this.markers.push(marker);
}

ResultsOverlay.prototype.addPolyline = function(polyline) {
  this.polylines.push(polyline);
}

ResultsOverlay.prototype.clear = function() {
  this.markers.invoke( "setMap", null);
  this.markers.clear();
  this.polylines.invoke( "setMap", null);
  this.polylines.each( function(polyline) {
    var path = polyline.getPath();
    while ( path.getLength()>0) {
      path.pop();
    }
  });
  this.polylines.clear();
  this.onRemove();
}

ResultsOverlay.prototype.bounds = function() {
  var bounds = new google.maps.LatLngBounds();
  this.markers.each( function(marker){
    bounds.extend(marker.getPosition());
  });
  return bounds;
}

  // Implement onRemove
ResultsOverlay.prototype.onRemove = function() {

 // Label is removed from the map, stop updating its position/text.
  for (var i = 0, I = this.listeners_.length; i < I; ++i) {
    google.maps.event.removeListener(this.listeners_[i]);
  }
};

  // Implement draw
ResultsOverlay.prototype.draw = function() {
  var my_label = this.get("label");

  this.markers.each(function(marker){
    marker.setOptions({ visible: true});
    this.listeners_.push(
      google.maps.event.addListener(marker, 'mouseover',
        function() { my_label.set("marker", marker); }));
    this.listeners_.push(
      google.maps.event.addListener(marker, 'mouseout',
        function() { my_label.hide(); }));
  }.bind(this));
};
