Skip to content
Snippets Groups Projects
Commit 32fd687b authored by Anthony Borghi's avatar Anthony Borghi
Browse files

Généralisation de la classe Printbox

Passage de l'objet nsVmap.Map en paramètre du constructeur
parent 500f524a
Branches
Tags
No related merge requests found
...@@ -18,11 +18,13 @@ goog.require('ol.interaction.Translate'); ...@@ -18,11 +18,13 @@ goog.require('ol.interaction.Translate');
nsVmap.nsToolsManager.PrintBox = function (opt_options) { nsVmap.nsToolsManager.PrintBox = function (opt_options) {
oVmap.log('nsVmap.nsToolsManager.PrintBox'); oVmap.log('nsVmap.nsToolsManager.PrintBox');
this.map_ = oVmap.getMap().getOLMap();
// Valeurs par défaut // Valeurs par défaut
opt_options = goog.isDefAndNotNull(opt_options) ? opt_options : {}; opt_options = goog.isDefAndNotNull(opt_options) ? opt_options : {};
this.oMap_ = (goog.isDefAndNotNull(opt_options["map_object"])? opt_options["map_object"]: oVmap.getMap());
this.map_ = this.oMap_.getOLMap();
/** /**
* The print box feature * The print box feature
* @private * @private
...@@ -45,7 +47,7 @@ nsVmap.nsToolsManager.PrintBox = function (opt_options) { ...@@ -45,7 +47,7 @@ nsVmap.nsToolsManager.PrintBox = function (opt_options) {
* @type {ol.layer.Vector} * @type {ol.layer.Vector}
* @private * @private
*/ */
this.oOpenLayersOverlay_ = oVmap.getMap().addVectorLayer(); this.oOpenLayersOverlay_ = this.oMap_.addVectorLayer();
/** /**
* @type {ol.Collection} * @type {ol.Collection}
...@@ -110,7 +112,7 @@ nsVmap.nsToolsManager.PrintBox.prototype.managePrintBox = function (sInteraction ...@@ -110,7 +112,7 @@ nsVmap.nsToolsManager.PrintBox.prototype.managePrintBox = function (sInteraction
this.unlistenMapMovements(); this.unlistenMapMovements();
// Ajoute l'interaction de déplacement de la printBox // Ajoute l'interaction de déplacement de la printBox
oVmap.getMap().setInteraction(this.translateInteraction_, sInteractionName); this.oMap_.setInteraction(this.translateInteraction_, sInteractionName);
}; };
...@@ -122,12 +124,23 @@ nsVmap.nsToolsManager.PrintBox.prototype.unmanagePrintBox = function () { ...@@ -122,12 +124,23 @@ nsVmap.nsToolsManager.PrintBox.prototype.unmanagePrintBox = function () {
oVmap.log('nsVmap.nsToolsManager.PrintBox.unmanagePrintBox'); oVmap.log('nsVmap.nsToolsManager.PrintBox.unmanagePrintBox');
// remove l'action de modification // remove l'action de modification
oVmap.getMap().removeActionsAndTooltips(); this.oMap_.removeActionsAndTooltips();
this.drawPrintBox(); this.drawPrintBox();
this.listenMapMovements(); this.listenMapMovements();
}; };
/**
* Cancel the printZone manage interaction and adapt the view on it
* @export
*/
nsVmap.nsToolsManager.PrintBox.prototype.unmanagePrintBoxAndLock = function () {
oVmap.log('nsVmap.nsToolsManager.PrintBox.unmanagePrintBox');
// remove l'action de modification
this.oMap_.removeActionsAndTooltips();
};
/** /**
* Get the print box scale * Get the print box scale
* @returns {Number|String} * @returns {Number|String}
...@@ -149,7 +162,7 @@ nsVmap.nsToolsManager.PrintBox.prototype.getScale = function () { ...@@ -149,7 +162,7 @@ nsVmap.nsToolsManager.PrintBox.prototype.getScale = function () {
nearest: true nearest: true
}); });
var scale = oVmap.getMap().getScale(); var scale = this.oMap_.getScale();
setTimeout(function () { setTimeout(function () {
// Retrouve la position initiale // Retrouve la position initiale
...@@ -239,7 +252,7 @@ nsVmap.nsToolsManager.PrintBox.prototype.getExtent = function () { ...@@ -239,7 +252,7 @@ nsVmap.nsToolsManager.PrintBox.prototype.getExtent = function () {
*/ */
nsVmap.nsToolsManager.PrintBox.prototype.listenMapMovements = function () { nsVmap.nsToolsManager.PrintBox.prototype.listenMapMovements = function () {
this.printBoxEvent_ = oVmap.getMap().setEventOnMap('precompose', this.drawPrintBox, this); this.printBoxEvent_ = this.oMap_.setEventOnMap('precompose', this.drawPrintBox, this);
}; };
/** /**
...@@ -286,10 +299,12 @@ nsVmap.nsToolsManager.PrintBox.prototype.createPrintBox = function (printBoxSize ...@@ -286,10 +299,12 @@ nsVmap.nsToolsManager.PrintBox.prototype.createPrintBox = function (printBoxSize
var boxWidth = printBoxSize[0]; var boxWidth = printBoxSize[0];
var boxHeight = printBoxSize[1]; var boxHeight = printBoxSize[1];
var x1 = $('#map1').width() / 2 - boxWidth / 2; var sMapComponentId = this.map_.getViewport().getAttribute('id');
var x2 = $('#map1').width() / 2 + boxWidth / 2;
var y1 = $('#map1').height() / 2 - boxHeight / 2; var x1 = $('#' + sMapComponentId).width() / 2 - boxWidth / 2;
var y2 = $('#map1').height() / 2 + boxHeight / 2; var x2 = $('#' + sMapComponentId).width() / 2 + boxWidth / 2;
var y1 = $('#' + sMapComponentId).height() / 2 - boxHeight / 2;
var y2 = $('#' + sMapComponentId).height() / 2 + boxHeight / 2;
var point1 = [x1, y2]; var point1 = [x1, y2];
var point3 = [x2, y1]; var point3 = [x2, y1];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment