From a05e0fd36514c3364399464c5b832e9985093228 Mon Sep 17 00:00:00 2001 From: Armand Bahi <armand.bahi@veremes.com> Date: Fri, 2 Nov 2018 09:32:47 +0100 Subject: [PATCH] Add right-click to termine drawing --- .../module/javascript/app/vmap/map/map.js | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/module_vmap/module/javascript/app/vmap/map/map.js b/src/module_vmap/module/javascript/app/vmap/map/map.js index 7c0ba9a4..fbd9fabb 100644 --- a/src/module_vmap/module/javascript/app/vmap/map/map.js +++ b/src/module_vmap/module/javascript/app/vmap/map/map.js @@ -389,6 +389,12 @@ nsVmap.Map = function () { if (oVmap['properties']['is_mobile']) { this_.trackGPSPosition(); } + + // Termine les dessins par le clic droit + this.oOpenLayersMap_.getViewport().addEventListener('contextmenu', function (evt) { + evt.preventDefault(); + this_.termineDrawInteractions(); + }) }; /** @@ -1209,6 +1215,29 @@ nsVmap.Map.prototype.trackGPSPosition = function () { } }; +/** + * Termine all the draw interactions + * + */ +nsVmap.Map.prototype.termineDrawInteractions = function () { + oVmap.log('nsVmap.Map.prototype.termineDrawInteractions'); + + for (var i = 0; i < this.vmapInteractions_.length; i++) { + if (this.vmapInteractions_[i] instanceof ol.interaction.Draw) { + try { + // Termine le dessin en cours + this.vmapInteractions_[i].finishDrawing(); + // Desactive la fonctionnalié pour ne pas commencer un autre dessin + this.vmapInteractions_[i].setActive(false); + // Réactive la fonctionnalité + setTimeout(angular.bind(this, function(oDrawInteraction){ + oDrawInteraction.setActive(true); + }, this.vmapInteractions_[i]), 500); + } catch (e) {} + } + } +}; + /******************************************** * INTERFACE MOBILE *******************************************/ -- GitLab