//asigna metodos y atributos para el objeto de mapa
function inicializarMapa(mapa){
    mapa.longitudInicial = -3.161336;
    mapa.latitudInicial = 39.67406;
    mapa.zoomInicial = 7;
    mapa.tipoMapaInicial = 1;
    mapa.ponerTipo = mapaPonerTipo;
    mapa.ponerCentro = mapaPonerCentro;
    mapa.ponerMarcadorDraggable = mapaPonerMarcadorDraggable;
}

//METODOS DE CLASE
function mapaPonerTipo(tipoMapa){
    this.setMapType(tipoMapa2tipoGoogle(parseInt(tipoMapa)));
}

//coloca el centro y zoom del mapa
function mapaPonerCentro(latitud,longitud,zoom){
    if(!latitud || !longitud){
        latitud = this.latitudInicial;
        longitud = this.longitudInicial;
    }
    if(!zoom)
        zoom = this.zoomInicial;
    this.setCenter(new GLatLng(latitud,longitud),zoom);
}

/**
@desc Coloca en el mapa un marcador arrastrable y lo devuelve
@param double Latitud del marcador
@param double Longitud del marcador
@return GMarker Marcador recien creado
*/
function mapaPonerMarcadorDraggable(latitud,longitud){
    if(!latitud || !longitud){
        latitud = this.getCenter().lat();
        longitud = this.getCenter().lng();
    }
    var marcador = new GMarker(new GLatLng(latitud,longitud),{"draggable":true,"dragCrossMove":true});
    this.addOverlay(marcador);
    return marcador;
}
//FIN METODOS DE CLASE


//FUNCIONES GENERICAS
function tipoGoogle2tipoMapa(tipoGoogle){
    switch(tipoGoogle){
        case G_NORMAL_MAP:
            return 'roadmap';
        break;
        case G_SATELLITE_MAP:
            return 'satellite';
        break;
        case G_HYBRID_MAP:
            return 'hybrid';
        break;
    }
}

function tipoMapa2tipoGoogle(tipoMapa){
    switch(tipoMapa){
        case 'roadmap':
            return G_NORMAL_MAP;
        break;
        case 'satellite':
            return G_SATELLITE_MAP;
        break;
        case 'hybrid':
            return G_HYBRID_MAP;
        break;
    }
}
//FIN FUNCIONES GENERICAS