
   // Un rectangulo es un overlay  que limitado por una longitud/latitud en 
   // el mapa. Tiene un borde de una anchura determinada y un color y opcionalmente
   // puede ener un color de fondo semi-transparente. 
   function Rectangle(bounds, opt_weight, opt_color) 
   { 
     this.bounds_ = bounds; 
     this.weight_ = opt_weight || 2; 
     this.color_ = opt_color || "#888888"; 
   } 
   Rectangle.prototype = new GOverlay(); 
 
   // Crear el DIV representando el rectangulo. 
   Rectangle.prototype.initialize = function(map) 
   { 
     // Crear el DIV representando nuestro rectangulo
     var div = document.createElement("div"); 
     div.style.border = this.weight_ + "px solid " + this.color_; 
     div.style.position = "absolute"; 
 
     // Nuestro rectangulo es plano contra el mapa, asi que lo añadimos al
     // panel MAP_PANE , que está al mismo z-index que el mapa (i.e., 
     // por de bajo de las sombras de los marcadores GMARKERS) 
     map.getPane(G_MAP_MAP_PANE).appendChild(div); 
 
     this.map_ = map; 
     this.div_ = div; 
   } 
 
   // Quitar el DIV principal del map pane
   Rectangle.prototype.remove = function() 
   { 
     this.div_.parentNode.removeChild(this.div_); 
   } 
 
   // Copiar nuestros datos al nuevo rectangulo
   Rectangle.prototype.copy = function() 
   { 
      return new Rectangle(this.bounds_, this.weight_, this.color_, 
                       this.backgroundColor_, this.opacity_); 
   } 
 
   // Redibujar el ractangulo basado en la proyeccion actual y nivel de zoom
   Rectangle.prototype.redraw = function(force) 
   { 
     // Solo necesitamos redibujar si las coordenadas han cambiado
     if (!force) return; 
 
     // Calcular las coordenadas del DIV de las dos esquinas contrarias de los limites
     // para darle el tamaño y posicion de nuestro rectangulo
     var c1 = this.map_.fromLatLngToDivPixel(this.bounds_.getSouthWest()); 
     var c2 = this.map_.fromLatLngToDivPixel(this.bounds_.getNorthEast()); 
    
     // Ahora posicionar nuestro DIV basado en las coordenadas del DIV de los limites...
     this.div_.style.width  = Math.abs(c2.x - c1.x) + "px"; 
     this.div_.style.height = Math.abs(c2.y - c1.y) + "px"; 
     this.div_.style.left   = (Math.min(c2.x, c1.x) - this.weight_) + "px"; 
     this.div_.style.top    = (Math.min(c2.y, c1.y) - this.weight_) + "px"; 
   } 


   function inicializar_mapa(div_destino,latitud,longitud,rectangulo) 
   {
       if (GBrowserIsCompatible()) 
       {
          var map = new GMap2(document.getElementById(div_destino));
          map.setCenter(new GLatLng(latitud,longitud), 13);
          map.addControl(new GLargeMapControl());
          
          var rectangulo_ = rectangulo || false;
          if(rectangulo == true)
          {  //poner un rectangulo entre esas coordenadas...
             var bounds = map.getBounds();  
             var southWest = bounds.getSouthWest();
             var northEast = bounds.getNorthEast();
             var lngDelta  = (northEast.lng() - southWest.lng()) / 4;
             var latDelta = (northEast.lat() - southWest.lat()) / 4;
             var rectBounds = new GLatLngBounds( 
                                 new GLatLng(southWest.lat() + latDelta, southWest.lng() + lngDelta), 
                                 new GLatLng(northEast.lat() - latDelta, northEast.lng() - lngDelta)
                                 );           
             map.addOverlay(new Rectangle(rectBounds));
          }
          else
          { //posicion exacta en lugar de aproximada con un rectangulo...
             map.addOverlay(new GMarker(new GLatLng(latitud,longitud)));
          }
          
       }
   }


