From 9ff786cba848db270ad0dea871f5b68cea5f9c84 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Thu, 15 Mar 2018 13:25:48 +0100
Subject: [PATCH] getBounds method implemented

---
 .../src/main/js/map/AbstractCustomMap.js        | 17 +++++++++++++++++
 .../src/main/js/plugin/MinervaPluginProxy.js    |  7 +++++++
 2 files changed, 24 insertions(+)

diff --git a/frontend-js/src/main/js/map/AbstractCustomMap.js b/frontend-js/src/main/js/map/AbstractCustomMap.js
index 8aa7acaf55..0df2758771 100644
--- a/frontend-js/src/main/js/map/AbstractCustomMap.js
+++ b/frontend-js/src/main/js/map/AbstractCustomMap.js
@@ -1078,6 +1078,23 @@ AbstractCustomMap.prototype.getCenter = function () {
   return this.fromLatLngToPoint(coordinates);
 };
 
+AbstractCustomMap.prototype.getBounds = function () {
+  var self = this;
+  var bounds = self.getGoogleMap().getBounds();
+  var ne = bounds.getNorthEast();
+  var sw = bounds.getSouthWest();
+
+  var result = {
+    p1: this.fromLatLngToPoint(ne),
+    p2: this.fromLatLngToPoint(sw)
+  };
+  if (result.p2.x > result.p1.x) {
+    result.p2.x -= 360 * self.pixelsPerLonDegree_*self.zoomFactor;
+  }
+  return result;
+};
+
+
 /**
  * Sets zoom level for google maps.
  *
diff --git a/frontend-js/src/main/js/plugin/MinervaPluginProxy.js b/frontend-js/src/main/js/plugin/MinervaPluginProxy.js
index 0130243f84..92111fa47f 100644
--- a/frontend-js/src/main/js/plugin/MinervaPluginProxy.js
+++ b/frontend-js/src/main/js/plugin/MinervaPluginProxy.js
@@ -414,6 +414,13 @@ function createProjectMap(options) {
       }
       return submap.getCenter();
     },
+    getBounds: function (params) {
+      var submap = map.getSubmapById(params.modelId);
+      if (submap === null) {
+        throw new Error("Unknown modelId: " + params.modelId);
+      }
+      return submap.getBounds();
+    },
     fitBounds: function (params) {
       var submap = map.getSubmapById(params.modelId);
       if (submap === null) {
-- 
GitLab