Skip to content
Snippets Groups Projects
Commit 847e66e4 authored by Armand Bahi's avatar Armand Bahi
Browse files

Amélioration performances

parent f9f4d2c0
No related branches found
No related tags found
No related merge requests found
...@@ -446,6 +446,26 @@ nsVmap.MapCompare.prototype.mapCompareController = function ($scope, $window, $e ...@@ -446,6 +446,26 @@ nsVmap.MapCompare.prototype.mapCompareController = function ($scope, $window, $e
*/ */
this.duration = 1000; this.duration = 1000;
/**
* Timestamp of the last map center sync
*/
this.lastMapSyncCenter_ = 0;
/**
* Timestamp of the last map compare center sync
*/
this.lastCompareMapSyncCenter_ = 0;
/**
* Timestamp of the last map scale sync
*/
this.lastMapSyncScale_ = 0;
/**
* Timestamp of the last map compare scale sync
*/
this.lastCompareMapSyncScale_ = 0;
/** /**
* @type {ol.Map} * @type {ol.Map}
* @private * @private
...@@ -547,24 +567,30 @@ nsVmap.MapCompare.prototype.mapCompareController.prototype.startAnimation = func ...@@ -547,24 +567,30 @@ nsVmap.MapCompare.prototype.mapCompareController.prototype.startAnimation = func
this.animationDelay.start(); this.animationDelay.start();
}; };
/** /**
* Update the map size with animation * Update the map size with animation
* @returns {undefined} * @returns {undefined}
*/ */
nsVmap.MapCompare.prototype.mapCompareController.prototype.synchronizeMap = function () { nsVmap.MapCompare.prototype.mapCompareController.prototype.synchronizeMap = function () {
oVmap.log('nsVmap.MapCompare.prototype.mapCompareController.prototype.synchronizeMap'); oVmap.log('nsVmap.MapCompare.prototype.mapCompareController.prototype.synchronizeMap');
var this_ = this; var this_ = this;
// blocage infinite loop
// Synchro Échelle
oVmap.getMap().getOLMap().getTargetElement().addEventListener('mouseenter', function(){ oVmap.getMap().getOLMap().getTargetElement().addEventListener('mouseenter', function(){
oVmap.getMap().getOLMap().getView().on("change:resolution", this_.updateCompareScaleMap, this_); oVmap.getMap().getOLMap().on("moveend", this_.updateCompareScaleMap, this_);
this_.map.getView().un("change:resolution", this_.updateScaleMap, this_); this_.map.un("moveend", this_.updateScaleMap, this_);
}); });
this_.map.getTargetElement().addEventListener('mouseenter', function(){ this_.map.getTargetElement().addEventListener('mouseenter', function(){
oVmap.getMap().getOLMap().getView().un("change:resolution", this_.updateCompareScaleMap, this_); oVmap.getMap().getOLMap().un("moveend", this_.updateCompareScaleMap, this_);
this_.map.getView().on("change:resolution", this_.updateScaleMap, this_); this_.map.on("moveend", this_.updateScaleMap, this_);
}); });
// position du curseur sur l'autre carte
// Synchro centre
oVmap.getMap().getOLMap().on("pointerdrag", this_.updateCenterCompareMap, this_);
this_.map.on("pointerdrag", this_.updateCenterMap, this_);
// Synchro curseur sur l'autre carte
oVmap.getMap().getOLMap().on('pointermove', function(e){ oVmap.getMap().getOLMap().on('pointermove', function(e){
var coord = e.coordinate; var coord = e.coordinate;
//si le composant existe sur l'autre composant on le supprime //si le composant existe sur l'autre composant on le supprime
...@@ -623,50 +649,58 @@ nsVmap.MapCompare.prototype.mapCompareController.prototype.synchronizeMap = func ...@@ -623,50 +649,58 @@ nsVmap.MapCompare.prototype.mapCompareController.prototype.synchronizeMap = func
this_.targetOverlay_.setPosition(convertCoord); this_.targetOverlay_.setPosition(convertCoord);
}); });
// synchro de la carte avec la carte de comparaison
oVmap.getMap().getOLMap().on("pointerdrag", this_.updateCenterCompareMap, this_);
// synchro de la carte de comapraison avec la carte de base
this_.map.on("pointerdrag", this_.updateCenterMap, this_);
}; };
/** /**
* Update the map extent with animation * Update the map extent with animation
* @returns {undefined} * @returns {undefined}
*/ */
nsVmap.MapCompare.prototype.mapCompareController.prototype.updateCompareScaleMap = function(e){ nsVmap.MapCompare.prototype.mapCompareController.prototype.updateCompareScaleMap = function(e) { console.log('updateCompareScaleMap');
var this_ = this var this_ = this
this_.updateCenterCompareMap(); this_.updateCenterCompareMap();
oVmap.getMapCompare().setScale(oVmap.getMap().getScale()); oVmap.getMapCompare().setScale(oVmap.getMap().getScale());
this.lastCompareMapSyncScale_ = Date.now();
} }
/** /**
* Update the map extent with animation * Update the map extent with animation
* @returns {undefined} * @returns {undefined}
*/ */
nsVmap.MapCompare.prototype.mapCompareController.prototype.updateScaleMap = function(e){ nsVmap.MapCompare.prototype.mapCompareController.prototype.updateScaleMap = function(e) { console.log('updateScaleMap');
var this_ = this var this_ = this
this_.updateCenterMap(); this_.updateCenterMap();
oVmap.getMap().setScale(oVmap.getMapCompare().getScale()) oVmap.getMap().setScale(oVmap.getMapCompare().getScale());
this.lastMapSyncScale_ = Date.now();
} }
/** /**
* Update the map extent with animation * Update the map extent with animation
* @returns {undefined} * @returns {undefined}
*/ */
nsVmap.MapCompare.prototype.mapCompareController.prototype.updateCenterMap = function(e){ nsVmap.MapCompare.prototype.mapCompareController.prototype.updateCenterMap = function(e) {
var this_ = this
// Récupère l'étendue de la carte principale var this_ = this
var oldCenter = this_.map.getView().getCenter(); // Récupère l'étendue de la carte principale
var oldCenter = this_.map.getView().getCenter();
// Récupère l'ancienne et la nouvelle projection // Récupère l'ancienne et la nouvelle projection
var newProjection = oVmap.getMap().getOLMap().getView().getProjection().getCode(); var newProjection = oVmap.getMap().getOLMap().getView().getProjection().getCode();
var oldProjection = this_.map.getView().getProjection().getCode(); var oldProjection = this_.map.getView().getProjection().getCode();
var newCenter = ol.proj.transform(oldCenter, oldProjection, newProjection); var newCenter = ol.proj.transform(oldCenter, oldProjection, newProjection);
oVmap.getMap().getOLMap().getView().setCenter(newCenter); oVmap.getMap().getOLMap().getView().setCenter(newCenter);
this.lastMapSyncCenter_ = Date.now();
} }
/** /**
* Update the map extent with animation * Update the map extent with animation
* @returns {undefined} * @returns {undefined}
*/ */
nsVmap.MapCompare.prototype.mapCompareController.prototype.updateCenterCompareMap = function(e){ nsVmap.MapCompare.prototype.mapCompareController.prototype.updateCenterCompareMap = function(e) {
var this_ = this; var this_ = this;
// Récupère l'étendue de la carte principale // Récupère l'étendue de la carte principale
var oldCenter = oVmap.getMap().getOLMap().getView().getCenter(); var oldCenter = oVmap.getMap().getOLMap().getView().getCenter();
...@@ -677,6 +711,8 @@ nsVmap.MapCompare.prototype.mapCompareController.prototype.updateCenterCompareMa ...@@ -677,6 +711,8 @@ nsVmap.MapCompare.prototype.mapCompareController.prototype.updateCenterCompareMa
var newCenter = ol.proj.transform(oldCenter, oldProjection, newProjection); var newCenter = ol.proj.transform(oldCenter, oldProjection, newProjection);
this_['map'].getView().setCenter(newCenter); this_['map'].getView().setCenter(newCenter);
this.lastCompareMapSyncCenter_ = Date.now();
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment