Skip to content

Commit

Permalink
Corregido parámetro mirrorLayers y añadido parámetro showTOC
Browse files Browse the repository at this point in the history
  • Loading branch information
irenevinas committed Jul 16, 2020
1 parent 3b1da90 commit e1d564b
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 24 deletions.
5 changes: 5 additions & 0 deletions dist/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
"type": "boolean",
"name": "interface",
"position": 8
},
{
"type": "boolean",
"name": "showToc",
"position": 9
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion dist/mirrorpanel.ol.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/mirrorpanel.ol.min.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ Plugin que permite comparar varias capas dividiendo la pantalla en varias partes

- **interface**. Define si mostrar o no la interfaz del plugin.

- **showTOC**. si es *true* mostrará el control layerswitcher en las capas espejo.

# Eventos

# Multi idioma
Expand Down
5 changes: 5 additions & 0 deletions src/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
"type": "boolean",
"name": "interface",
"position": 8
},
{
"type": "boolean",
"name": "showToc",
"position": 9
}
]
}
Expand Down
13 changes: 11 additions & 2 deletions src/facade/js/mirrorpanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ export default class Mirrorpanel extends M.Plugin {
*/
this.interface = options.interface === undefined ? true : options.interface;

/**
* Enabled layerswitcher control on mirrors
* @type {boolean}
* @public
*/
this.showTOC = options.showTOC;
if (this.showTOC === undefined) this.showTOC = true;


/**
*@private
Expand Down Expand Up @@ -172,6 +180,7 @@ export default class Mirrorpanel extends M.Plugin {
showCursors: this.showCursors,
mirrorLayers: this.mirrorLayers,
defaultBaseLyrs: this.defaultBaseLyrs,
showTOC: this.showTOC
};

this.control_ = new MirrorpanelControl(values);
Expand Down Expand Up @@ -227,7 +236,7 @@ export default class Mirrorpanel extends M.Plugin {
this.control_.removeMaps();
this.control_.destroyMapsContainer();
this.map_.removeControls([this.control_]);
[this.control_, this.panel_, this.map_, this.collapsible, this.collapsed, this.modeViz, this.enabledKeyFunctions, this.showCursors, this.mirrorLayers, this.defaultBaseLyrs, this.interface] = [null, null, null, null, null, null, null, null, null, null, null];
[this.control_, this.panel_, this.map_, this.collapsible, this.collapsed, this.modeViz, this.enabledKeyFunctions, this.showCursors, this.mirrorLayers, this.defaultBaseLyrs, this.interface, this.showTOC] = [null, null, null, null, null, null, null, null, null, null, null, null];
}

/**
Expand Down Expand Up @@ -260,7 +269,7 @@ export default class Mirrorpanel extends M.Plugin {
* @api
*/
getAPIRest() {
return `${this.name}=${this.position}*!${this.collapsed}*!${this.collapsible}*!${this.modeViz}*!${this.enabledKeyFunctions}*!${this.showCursors}*!${this.mirrorLayers}*!${this.defaultBaseLyrs}*!${this.interface}`;
return `${this.name}=${this.position}*!${this.collapsed}*!${this.collapsible}*!${this.modeViz}*!${this.enabledKeyFunctions}*!${this.showCursors}*!${this.mirrorLayers}*!${this.defaultBaseLyrs}*!${this.interface}*!${this.showTOC}`;
}

/**
Expand Down
42 changes: 23 additions & 19 deletions src/facade/js/mirrorpanelcontrol.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,9 @@ export default class MirrorpanelControl extends M.Control {
/**
* Defining mirror maps variables
*/
this.mapL = {
A: null,
B: null,
C: null,
D: null,
}
this.lyrCursor = {
A: null,
B: null,
C: null,
D: null,
}
this.featureLyrCursor = {
A: null,
B: null,
C: null,
D: null,
}
this.mapL = { A: null, B: null, C: null, D: null, }
this.lyrCursor = { A: null, B: null, C: null, D: null, }
this.featureLyrCursor = { A: null, B: null, C: null, D: null, }

/**
* Defining cursor style
Expand Down Expand Up @@ -100,6 +85,13 @@ export default class MirrorpanelControl extends M.Control {
*/
this.mirrorLayers = values.mirrorLayers;

/**
* Enable layerswitcher control
* @public
* @public {Array}
*/
this.showTOC = values.showTOC;

this.createMapContainers();
}

Expand Down Expand Up @@ -134,7 +126,12 @@ export default class MirrorpanelControl extends M.Control {
}

this.mapL['A'] = map;

if (this.mirrorLayers.length > 0) {
this.mapL['A'].addLayers(this.mirrorLayers);
this.mapL['A'].getLayers().forEach((l) => {
if (l.zindex_ !== 0) { l.setVisible(false); }
});
}
if (this.showCursors) { this.addLayerCursor('A'); }
return new Promise((success, fail) => {
let templateOptions = '';
Expand Down Expand Up @@ -300,13 +297,20 @@ export default class MirrorpanelControl extends M.Control {
this.mapL[mapLyr] = M.map({
container: 'mapjs' + mapLyr,
layers: defLyr,
controls: this.showTOC ? ['layerswitcher'] : '',
center: this.map_.getCenter(),
projection: this.map_.getProjection().code + '*' + this.map_.getProjection().units,
zoom: this.map_.getZoom(),
});
this.mapL[mapLyr].getMapImpl().setView(this.map_.getMapImpl().getView());

if (this.showCursors) { this.addLayerCursor(mapLyr); }
if (this.mirrorLayers.length > 0) {
this.mapL[mapLyr].addLayers(this.mirrorLayers);
this.mapL[mapLyr].getLayers().forEach((l) => {
if (l.zindex_ !== 0) { l.setVisible(false); }
});
}
this.mapL[mapLyr].refresh();
}

Expand Down
11 changes: 10 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@ const map = M.map({
x: -667143.31,
y: 4493011.77,
},
controls: ['scale', 'location'],
controls: ['scale', 'location', 'layerswitcher'],
projection: "EPSG:3857*m",
zoom: 8,
});

let capasPNOA = [
'WMS*PNOA 2015*https://www.ign.es/wms/pnoa-historico*PNOA2015',
'WMS*PNOA 2016*https://www.ign.es/wms/pnoa-historico*PNOA2016',
'WMS*PNOA 2017*https://www.ign.es/wms/pnoa-historico*PNOA2017',
'WMS*PNOA 2018*https://www.ign.es/wms/pnoa-historico*PNOA2018',
];

let defaultBaseLyrs = [
new M.layer.WMTS({
url: 'http://www.ign.es/wmts/ign-base?',
Expand Down Expand Up @@ -65,6 +73,7 @@ const mpMirrorPanel = new Mirrorpanel({
collapsible: true, // El botón para desplegar/replegar el plugin no aparece (false) o sí aparece(true)
collapsed: false, // El panel del plugin se muestra desplegado (false) o replegado (true)
modeViz: 0,
mirrorLayers: capasPNOA,
defaultBaseLyrs: defaultBaseLyrs, // Array de capas para los mapas espejo en formato StringAPICNIG
enabledKeyFunctions: true, // Están habilitadas los comandos por teclado
showCursors: true, // Se muestran los cursores
Expand Down

0 comments on commit e1d564b

Please sign in to comment.