﻿// JScript File

var MapFrame = GetMapFrame(); 

function inicializarMapa(mapaVista)
{
    MapFrame.inicializarMapa(mapaVista)                   
} 

function toggleControl(element) {
    MapFrame = GetMapFrame(); 
    MapFrame.toggleControl(element);
}   

function pedirMapaInicial(){
   MapFrame = GetMapFrame(); 
   MapFrame.pedirMapaInicial();
}

function pedirMapaInicialConCoord(x,y,zoom) {
    MapFrame = GetMapFrame();
    MapFrame.pedirMapaInicialConCoord(x,y,zoom);
}

function pedirMapa(xMin, yMin, xMax, yMax){
   /*******************************************************
   Pide mapa según un BoundingBox pasado
   ********************************************************/
   MapFrame.pedirMapa(xMin, yMin, xMax, yMax);
}

function pedirMapaSeleccion(numSel, rotuloSel, xMin, yMin, xMax, yMax){
   MapFrame.pedirMapaSeleccion(numSel, rotuloSel, xMin, yMin, xMax, yMax)
} 

function setMapCenter(x, y, zoomlevel){
    //Sets map center to received coordinates.
    MapFrame.setMapCenter(x, y, zoomlevel);
}

function setMapZoom(zoomlevel){
    //Sets map zoom to received zoomlevel.
    MapFrame.setMapZoom(zoomlevel);
}

function seleccion(numsel,rotulosel,xMin, yMin, xMax, yMax){
    //Set selection and zoom to this selection
    MapFrame.seleccion(numsel,rotulosel,xMin, yMin, xMax, yMax);
}

function seleccionConZoom(numsel,rotulosel,xMin, yMin, xMax, yMax, resolution){
    //Set selection and zoom
    MapFrame.seleccionConZoom(numsel,rotulosel,xMin, yMin, xMax, yMax, resolution);        
}

function seleccionSinZoom(numsel,rotulosel,xMin, yMin, xMax, yMax){
    //Set selection to this selection
    MapFrame.seleccionSinZoom(numsel,rotulosel,xMin, yMin, xMax, yMax);
}

function setZoomToExtent(xMin, yMin, xMax, yMax){
    //Sets map to extent (bounding box).
    MapFrame.setZoomToExtent(xMin, yMin, xMax, yMax);
}

function getNumSelection(){
    //Gets map numSelection
    return MapFrame.getNumSelection();   
}

function getRotuloSelection(){
    //Gets map Rotulo Selection
    return MapFrame.getRotuloSelection();   
}

function setLeyenda(leyenda){
    //Sets map with the selected leyenda.
    MapFrame.setLeyenda(leyenda);
}

function getLeyenda(){
    //Gets map Leyenda
    return MapFrame.getLeyenda();   
}

function acercar(zoom, xMin, yMin, xMax, yMax){
    //Numbers of zoom in or out
    MapFrame.acercar(zoom, xMin, yMin, xMax, yMax);
}

function cambiaVista(vista, xMin, yMin, xMax, yMax, rotulo, imageType, key){
    //Change the layer that is shown
    MapFrame.cambiaVista(vista, xMin, yMin, xMax, yMax, rotulo, imageType, key);
}

//---------------------------------------------------------------------//
function identificar(){ 
 	/**************************************************
	
	Inicia la operación de identificación de elementos.
	
	**************************************************/	
	MapFrame.identificar();
	
}

function getEscala(){
    /*************************************************
    Obtiene la escala del mapa en concreto
    **************************************************/
    return MapFrame.getEscala();
}

function getZoom(){
    /*************************************************
    Obtiene el zoom del mapa en concreto
    **************************************************/
    return MapFrame.getZoom();
}

function zoomTo(zoom){
    /*************************************************
    Actualiza el zoom del mapa en concreto
    **************************************************/
    MapFrame.zoomTo(zoom);
}

function getZoomPrevio(){
    /*************************************************
    Obtiene el zoom previo del mapa en concreto
    **************************************************/
    return MapFrame.getZoomPrevio();
}

function getLeyenda(){
    /*************************************************
    Obtiene la leyenda del mapa
    **************************************************/
    return MapFrame.getLeyenda();
}   

function refrescarMapa(){
    /*************************************************
    Refresca el mapa actual
    **************************************************/
    MapFrame = GetMapFrame(); 
    MapFrame.refrescarMapa();
} 

function setCenter(longitud, latitud, zoom){
    /*************************************************
    Centra el mapa según un punto (long y lat) y un zoom seleccionado
    **************************************************/ 
    MapFrame.setCenter(longitud,latitud,zoom);
}

function zoomSeleccion(){
    /**************************************************
    Hace zoom a la ultima seleccion
    ***************************************************/
    MapFrame.zoomSeleccion();
}

function getScale(){
    /**************************************************
    Obtiene la escala del mapa
    ***************************************************/
    return MapFrame.getScale();
}

function setScale(scale){
    /**************************************************
    Actualiza el valor de la escala del mapa con el valor introducido
    ***************************************************/
    MapFrame.setScale(scale);
}

function limpiarMapa(){
    /**************************************************
    Borra las selecciones y leyendas y pide mapa
    ***************************************************/
    MapFrame.limpiarMapa();
}

function getExtent(){
    /***************************************************
    Devuelve el BoundingBox del mapa actual
    ***************************************************/    
    return MapFrame.getExtent();
}

function getSize(){
    /****************************************************
    Devuelve el tamaño, en pixels del div que contiene el mapa
    ****************************************************/
    return MapFrame.getSize();
}