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 7c0ba9a4a13165ccacc01ee5c7584bd9b561101d..fbd9fabb1a9b9305ce02faa83d8b38f4bfa9b227 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 *******************************************/