CP-CHAP-03 - Projection con zoom y center

Prueba de setProjection con zoom y center

by SIGC

HTML

<link rel="stylesheet" href="https://sigc.desarrollo.guadaltel.es/mapea42_dev/assets/css/mapea.ol.min.css">
<link rel="stylesheet" href="https://sigc.desarrollo.guadaltel.es/mapea42_dev/plugins/printer/printer.min.css">
<script src="https://sigc.desarrollo.guadaltel.es/mapea42_dev/vendor/browser-polyfill.js"></script>
<script src="https://sigc.desarrollo.guadaltel.es/mapea42_dev/js/mapea.ol.min.js"></script>
<script src="https://sigc.desarrollo.guadaltel.es/mapea42_dev/js/configuration.js"></script>
<script src="https://sigc.desarrollo.guadaltel.es/mapea42_dev/plugins/printer/printer.ol.min.js"></script>
<input type="button" onclick="javascript:hacerZoom();" value="Zoom" />
<input type="button" onclick="javascript:setCobertura();" value="Bbox" />
<input type="button" onclick="javascript:setMaxCobertura();" value="MaxExtent" />
<input type="button" onclick="javascript:setProyeccion();" value="Projection" />
<input type="button" onclick="javascript:setCentro();" value="Centro" />
<input type="button" onclick="javascript:addEtiqueta();" value="Label" />

<div id="map"></div>

CSS

html,
body,
#map {
  padding: 0;
  margin: 0;
  width: 100%;
  height: 100%;
}

JavaScript

var mapajs = M.map({
	container:"map",
  layers:["WMS*MTA*http://www.ideandalucia.es/wms/mta400r_2008?*MTA400*true"],
  controls: ["mouse","layerswitcher"] 
  });
  
/** Zoom **/
function hacerZoom(){
	mapajs.setZoom(6);
}

/** Bbox **/
function setCobertura(){
mapajs.setBbox ([323020,4126873,374759,4152013]);
}

/** MaxExtent **/
function setMaxCobertura(){
	// mapajs.setMaxExtent ([323020,4126873,374759,4152013]);
	   mapajs.zoomToMaxExtent();
}

/** Projection **/
function setProyeccion(){
	mapajs.setProjection ("EPSG:4326*d");
}

/** Center **/
function setCentro(){
  //modo objeto
  mapajs.setCenter({x:211000,
                    y:4040000,
                    draw: true});  
  //modo cadena
  //mapajs.setCenter("211000,4040000*true");
}

/** Etiqueta **/
function addEtiqueta(){
     mapajs.addLabel("texto <b>con html</b>",[211000, 4040000]);
    //mapajs.addLabel("texto <b>con html</b>"); //se añade en el centro establecido
}