function AddressOverlay(opt_options) {
  // Initialization
  this.setValues(opt_options);
};

AddressOverlay.prototype = new google.maps.OverlayView;

  // Implement onAdd
AddressOverlay.prototype.onAdd = function() {
  this.marker = new google.maps.Marker({
    map: this.getMap(),
    visible: false
  });
  var marker = this.marker;
  var mapView = this.get("mapView");
 // Ensures the label is redrawn if the text or position is changed.
  var my_label = this.get("label");
  this.listeners_ = [
    google.maps.event.addListener(marker, 'mouseover',
      function() { my_label.set("marker", marker); }),
    google.maps.event.addListener(marker, 'mouseout',
      function() { my_label.hide(); }),
    google.maps.event.addListener(marker,"click", function() {
      var position = this.get("position");

        // set option sur infoWindow avant
      var htmlProducer = new HtmlContentProducer(
        { from: I18n.t("itineraries.map.from_address"),
          to: I18n.t("itineraries.map.to_address"),
          topoType: "address",
          topoId: (parseFloat(position.lat())+"-"+parseFloat(position.lng())).sub('.','-',2),
          name: this.get("text"),
          lat: position.lat(),
          lng: position.lng() });

      mapView.infoWindow.setOptions(
        { position: position,
          content: htmlProducer.produce() });

      mapView.infoWindow.open(marker.getMap(), marker)})
  ];
};

AddressOverlay.prototype.hide = function() {
  this.get("mapView").infoWindow.close();
  this.marker.setOptions({ visible: false });
};

  // Implement onRemove
AddressOverlay.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) {
    maps.google.event.removeListener(this.listeners_[i]);
  }
};

  // Implement draw
AddressOverlay.prototype.draw = function() {
  if (this.get("geocoderResponse")!=undefined) {
    var position = this.get("geocoderResponse")["geometry"]["location"];
    this.marker.setOptions({
      visible: true,
      icon: new google.maps.MarkerImage( "/images/markers/address.png",
        new google.maps.Size( 22, 22),
        new google.maps.Point(0,0),
        new google.maps.Point(10,10)),
      text: this.get("geocoderResponse")["formatted_address"].sub(/, France$/, ''),
      position: position });


  } else {
    this.hide();
  }
};
