CP-CHAP-03 - Projection con zoom y center
Prueba de setProjection con zoom y center
by SIGC
HTML
<script src="https://sigc.desarrollo.guadaltel.es/mapea5/js/mapea.ol.min.js"></script>
<script src="https://sigc.desarrollo.guadaltel.es/mapea5/js/configuration.js"></script>
<link rel="stylesheet" href="https://sigc.desarrollo.guadaltel.es/mapea5/assets/css/mapea.ol.min.css">
<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 {
margin: 0;
padding: 0;
height: 100%;
overflow: hidden;
}
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
}