diff --git a/frontend-js/src/main/js/map/surface/AbstractSurfaceElement.js b/frontend-js/src/main/js/map/surface/AbstractSurfaceElement.js index 50036f25fad10b526ba36ec05dfd74001c2c71a3..83156cb3e6ecc7e7e9f3085dac3b77b3e8ded385 100644 --- a/frontend-js/src/main/js/map/surface/AbstractSurfaceElement.js +++ b/frontend-js/src/main/js/map/surface/AbstractSurfaceElement.js @@ -4,7 +4,8 @@ * Class representing abstract overlay element on the map relevant for a * specific layout. */ -function AbstractOverlayElement() { +function AbstractOverlayElement(params) { + this.setCustomMap(params.map); } AbstractOverlayElement.prototype.getIdentifiedElement = function() { @@ -21,4 +22,17 @@ AbstractOverlayElement.prototype.setIdentifiedElement = function(identifiedEleme this._identifiedElement = identifiedElement; }; +/** + * Returns {@link AbstractCustomMap} where surface is located. + * + * @returns {@link AbstractCustomMap} where surface is located + */ +AbstractOverlayElement.prototype.getCustomMap = function() { + return this._customMap; +}; + +AbstractOverlayElement.prototype.setCustomMap = function(customMap) { + this._customMap = customMap; +}; + module.exports = AbstractOverlayElement; diff --git a/frontend-js/src/main/js/map/surface/AliasSurface.js b/frontend-js/src/main/js/map/surface/AliasSurface.js index 89caad078dc240853f33d2c3d52685679c645c93..4ded4d3fa6557156163d51014af3cedb291dbe10 100644 --- a/frontend-js/src/main/js/map/surface/AliasSurface.js +++ b/frontend-js/src/main/js/map/surface/AliasSurface.js @@ -14,14 +14,11 @@ var IdentifiedElement = require('../data/IdentifiedElement'); */ function AliasSurface(params) { // call super constructor - AbstractSurfaceElement.call(); + AbstractSurfaceElement.call(this, params); // google map object associated with the alias this.gmapObj = params.gmapObj; - // AbstractCustomMap where the alias is located - this.customMap = params.map; - // original data this.aliasData = params.alias; @@ -30,7 +27,7 @@ function AliasSurface(params) { var aliasOverlayData = self; return function() { self.getCustomMap() - .openInfoWindowForAlias(aliasOverlayData.aliasData.getId(), aliasOverlayData.customMap.getId()); + .openInfoWindowForAlias(aliasOverlayData.aliasData.getId(), aliasOverlayData.getCustomMap().getId()); }; })(); google.maps.event.addListener(this.gmapObj, 'click', onclick); @@ -49,9 +46,6 @@ AliasSurface.prototype.setMap = function(map) { this.gmapObj.setMap(map); }; -AliasSurface.prototype.getCustomMap = function() { - return this.customMap; -}; AliasSurface.prototype.setColor = function(color) { this._color = color; this.gmapObj.setOptions({ @@ -73,8 +67,8 @@ AliasSurface.prototype.setBoundsForAlias = function(startX, endX) { var pointA = new google.maps.Point(this.aliasData.x + startX * this.aliasData.width, this.aliasData.y); var pointB = new google.maps.Point(this.aliasData.x + endX * this.aliasData.width, this.aliasData.y + this.aliasData.height); - var latLngA = this.customMap.fromPointToLatLng(pointA); - var latLngB = this.customMap.fromPointToLatLng(pointB); + var latLngA = this.getCustomMap().fromPointToLatLng(pointA); + var latLngB = this.getCustomMap().fromPointToLatLng(pointB); var bounds = new google.maps.LatLngBounds(); bounds.extend(latLngA); diff --git a/frontend-js/src/main/js/map/surface/ReactionSurface.js b/frontend-js/src/main/js/map/surface/ReactionSurface.js index 1a38b8d182337f52d1f978d333824b990534b3b7..76383c3c19aba8012b5ea8c15607bfe97378ac42 100644 --- a/frontend-js/src/main/js/map/surface/ReactionSurface.js +++ b/frontend-js/src/main/js/map/surface/ReactionSurface.js @@ -25,11 +25,10 @@ var IdentifiedElement = require('../data/IdentifiedElement'); */ function ReactionSurface(params) { // call super constructor - AbstractSurfaceElement.call(); + AbstractSurfaceElement.call(this, params); var overlayData = params.layoutReaction; this.setReactionData(params.reaction); - this.setCustomMap(params.map); var color = params.color; this.width = 5.0; @@ -273,18 +272,6 @@ ReactionSurface.prototype.getReactionData = function() { return this.reactionData; }; -/** - * Returns {@link AbstractCustomMap} where marker is located. - * - * @returns {@link AbstractCustomMap} where marker is located - */ -ReactionSurface.prototype.getCustomMap = function() { - return this.customMap; -}; - -ReactionSurface.prototype.setCustomMap = function(customMap) { - this.customMap = customMap; -}; ReactionSurface.prototype.getId = function() { return this._id;