Skip to content
Snippets Groups Projects
Commit 156b4213 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

common functionality extarcted to AbstractSurface

parent 71bccfb8
No related branches found
No related tags found
1 merge request!45Resolve "Clicking on map element"
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
* Class representing abstract overlay element on the map relevant for a * Class representing abstract overlay element on the map relevant for a
* specific layout. * specific layout.
*/ */
function AbstractOverlayElement() { function AbstractOverlayElement(params) {
this.setCustomMap(params.map);
} }
AbstractOverlayElement.prototype.getIdentifiedElement = function() { AbstractOverlayElement.prototype.getIdentifiedElement = function() {
...@@ -21,4 +22,17 @@ AbstractOverlayElement.prototype.setIdentifiedElement = function(identifiedEleme ...@@ -21,4 +22,17 @@ AbstractOverlayElement.prototype.setIdentifiedElement = function(identifiedEleme
this._identifiedElement = identifiedElement; 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; module.exports = AbstractOverlayElement;
...@@ -14,14 +14,11 @@ var IdentifiedElement = require('../data/IdentifiedElement'); ...@@ -14,14 +14,11 @@ var IdentifiedElement = require('../data/IdentifiedElement');
*/ */
function AliasSurface(params) { function AliasSurface(params) {
// call super constructor // call super constructor
AbstractSurfaceElement.call(); AbstractSurfaceElement.call(this, params);
// google map object associated with the alias // google map object associated with the alias
this.gmapObj = params.gmapObj; this.gmapObj = params.gmapObj;
// AbstractCustomMap where the alias is located
this.customMap = params.map;
// original data // original data
this.aliasData = params.alias; this.aliasData = params.alias;
...@@ -30,7 +27,7 @@ function AliasSurface(params) { ...@@ -30,7 +27,7 @@ function AliasSurface(params) {
var aliasOverlayData = self; var aliasOverlayData = self;
return function() { return function() {
self.getCustomMap() self.getCustomMap()
.openInfoWindowForAlias(aliasOverlayData.aliasData.getId(), aliasOverlayData.customMap.getId()); .openInfoWindowForAlias(aliasOverlayData.aliasData.getId(), aliasOverlayData.getCustomMap().getId());
}; };
})(); })();
google.maps.event.addListener(this.gmapObj, 'click', onclick); google.maps.event.addListener(this.gmapObj, 'click', onclick);
...@@ -49,9 +46,6 @@ AliasSurface.prototype.setMap = function(map) { ...@@ -49,9 +46,6 @@ AliasSurface.prototype.setMap = function(map) {
this.gmapObj.setMap(map); this.gmapObj.setMap(map);
}; };
AliasSurface.prototype.getCustomMap = function() {
return this.customMap;
};
AliasSurface.prototype.setColor = function(color) { AliasSurface.prototype.setColor = function(color) {
this._color = color; this._color = color;
this.gmapObj.setOptions({ this.gmapObj.setOptions({
...@@ -73,8 +67,8 @@ AliasSurface.prototype.setBoundsForAlias = function(startX, endX) { ...@@ -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 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 var pointB = new google.maps.Point(this.aliasData.x + endX * this.aliasData.width, this.aliasData.y
+ this.aliasData.height); + this.aliasData.height);
var latLngA = this.customMap.fromPointToLatLng(pointA); var latLngA = this.getCustomMap().fromPointToLatLng(pointA);
var latLngB = this.customMap.fromPointToLatLng(pointB); var latLngB = this.getCustomMap().fromPointToLatLng(pointB);
var bounds = new google.maps.LatLngBounds(); var bounds = new google.maps.LatLngBounds();
bounds.extend(latLngA); bounds.extend(latLngA);
......
...@@ -25,11 +25,10 @@ var IdentifiedElement = require('../data/IdentifiedElement'); ...@@ -25,11 +25,10 @@ var IdentifiedElement = require('../data/IdentifiedElement');
*/ */
function ReactionSurface(params) { function ReactionSurface(params) {
// call super constructor // call super constructor
AbstractSurfaceElement.call(); AbstractSurfaceElement.call(this, params);
var overlayData = params.layoutReaction; var overlayData = params.layoutReaction;
this.setReactionData(params.reaction); this.setReactionData(params.reaction);
this.setCustomMap(params.map);
var color = params.color; var color = params.color;
this.width = 5.0; this.width = 5.0;
...@@ -273,18 +272,6 @@ ReactionSurface.prototype.getReactionData = function() { ...@@ -273,18 +272,6 @@ ReactionSurface.prototype.getReactionData = function() {
return this.reactionData; 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() { ReactionSurface.prototype.getId = function() {
return this._id; return this._id;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment