[Wiki] gestión extensión máxima
by Francisco
HTML
<script src="https://mapea4-sigc.juntadeandalucia.es/js/mapea-5.0.1.ol.min.js"></script>
<link rel="stylesheet" href="https://mapea4-sigc.juntadeandalucia.es/assets/css/mapea-5.0.1.ol.min.css">
<script src="https://mapea4-sigc.juntadeandalucia.es/js/configuration-5.0.1.js"></script>
<div id="map"></div>
CSS
html,
body,
#map {
padding: 0;
margin: 0;
width: 100%;
height: 100%;
}
JavaScript
// ESCENARIO 1
// Capa WMS, no hay definida extension maxima
/*let layerWMS = new M.layer.WMS({
url: 'http://www.callejerodeandalucia.es/servicios/base/wms?',
name: 'red_hidrografica',
legend: 'Ríos',
transparent: false,
tiled: false
});
mapajs = M.map({
container: "map",
layers: [layerWMS],
controls: ["layerswitcher"],
projection: "EPSG:25830*m"
});*/
// ESCENARIO 2
// Capa WMS, definida extension maxima para el mapa
/*let layerWMS = new M.layer.WMS({
url: 'http://www.callejerodeandalucia.es/servicios/base/wms?',
name: 'red_hidrografica',
legend: 'Ríos',
transparent: false,
tiled: false
});
mapajs = M.map({
container: "map",
layers: [layerWMS],
controls: ["layerswitcher","mouse"],
projection: "EPSG:25830*m",
maxExtent: [216000,3970000,520000,4290000]
});*/
// Se puede especificar un maxExtent específico a la capa que solo le afectará a ella.
//layerWMS.setMaxExtent([ 100401.203125, 3988490.25, 620454.9375, 4288203 ]);
// ESCENARIO 3
// Fichero wmcfile con múltiples capas. La capa'batimetria' tiene definida su propia extension maxima
// http://mapea4-sigc.juntadeandalucia.es/mapea/files/wmc/mapa.xml
/*mapajs = M.map({
container: 'map',
controls: ["layerswitcher"],
wmcfiles: ['mapa']
});*/
// ESCENARIO 4
// Capa OSM y capa WMS en mapa sin extension maxima
/*let layerWMS = new M.layer.WMS({
url: 'http://www.callejerodeandalucia.es/servicios/base/wms?',
name: 'red_hidrografica',
legend: 'Ríos',
transparent: true,
tiled: false
});
mapajs = M.map({
container: 'map',
controls: ["layerswitcher"],
layers: ['OSM',layerWMS]
});*/
// ESCENARIO 5
// WMTS
mapajs = M.map({
container: "map",
layers: ["WMTS*http://www.ign.es/wmts/pnoa-ma?*OI.OrthoimageCoverage*EPSG:25830*PNOA"],
//center: [363063, 4150610],
//zoom: '4',
controls: ['layerswitcher','panzoombar','mouse'],
...