From 48e5a78c6e88fc6c68d36a3ca542d621c5226910 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Mon, 31 Jul 2017 18:24:22 +0200
Subject: [PATCH] implementation of getModelId and getBounds

---
 .../js/map/surface/AbstractSurfaceElement.js  | 21 ++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/frontend-js/src/main/js/map/surface/AbstractSurfaceElement.js b/frontend-js/src/main/js/map/surface/AbstractSurfaceElement.js
index 4a8d7b2b58..d657fd6bce 100644
--- a/frontend-js/src/main/js/map/surface/AbstractSurfaceElement.js
+++ b/frontend-js/src/main/js/map/surface/AbstractSurfaceElement.js
@@ -15,6 +15,9 @@ function AbstractOverlayElement(params) {
 
   self.registerListenerType("onClick");
   self.setCustomMap(params.map);
+  if (params.element !== undefined && params.element !== null) {
+    self.setIdentifiedElement(params.element);
+  }
   self._googleMapObjects = [];
 
   if (params.onClick !== undefined) {
@@ -42,7 +45,7 @@ AbstractOverlayElement.prototype.getBounds = function() {
   for (var i = 0; i < this.getGoogleMapObjects().length; i++) {
     bounds.extend(this.getGoogleMapObjects()[i].getBounds().getSouthWest());
     bounds.extend(this.getGoogleMapObjects()[i].getBounds().getNorthEast());
-  } 
+  }
   return bounds;
 };
 
@@ -96,6 +99,10 @@ AbstractOverlayElement.prototype.getIdentifiedElement = function() {
   return this._identifiedElement;
 };
 
+AbstractOverlayElement.prototype.getModelId = function() {
+  return this.getIdentifiedElement().getModelId();
+};
+
 AbstractOverlayElement.prototype.updateIdentifiedElement = function(identifiedElement) {
   if (identifiedElement.getColor() !== undefined) {
     this.setColor(identifiedElement.getColor());
@@ -106,6 +113,18 @@ AbstractOverlayElement.prototype.setIdentifiedElement = function(identifiedEleme
   this._identifiedElement = identifiedElement;
 };
 
+AbstractOverlayElement.prototype.getBounds = function() {
+  var self = this;
+  var bounds = new google.maps.LatLngBounds();
+  for (var i = 0; i < self.getGoogleMapObjects().length; i++) {
+    var elementBounds = self.getGoogleMapObjects()[i].getBounds();
+    bounds.extend(elementBounds.getNorthEast());
+    bounds.extend(elementBounds.getSouthWest());
+  }
+
+  return bounds;
+};
+
 /**
  * Returns {@link AbstractCustomMap} where surface is located.
  * 
-- 
GitLab