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

common functions extracted for Marker classes

parent 468f91a8
No related branches found
No related tags found
1 merge request!45Resolve "Clicking on map element"
......@@ -20,6 +20,15 @@ function AbstractMarker(params) {
AbstractMarker.prototype = Object.create(ObjectWithListeners.prototype);
AbstractMarker.prototype.constructor = AbstractMarker;
/**
* Returns identifier of this object.
*
* @returns identifier of this object
*/
AbstractMarker.prototype.getId = function() {
return this.getIdentifiedElement().getId();
};
/**
* Returns icon of the marker.
*
......@@ -156,7 +165,7 @@ AbstractMarker.prototype.getGoogleMarker = function() {
* @returns string marker type
*/
AbstractMarker.prototype.getType = function() {
throw new Error("Not implemented");
return this.getIdentifiedElement().getType();
};
AbstractMarker.prototype.getIdentifiedElement = function() {
......
......@@ -15,24 +15,10 @@ function AliasMarker(element, map) {
element : element,
map : map
});
// id of the alias to which marker is connected
this.setId(element.getId());
}
AliasMarker.prototype = Object.create(AbstractMarker.prototype);
AliasMarker.prototype.constructor = AliasMarker;
/**
* Returns identifier of this object.
*
* @returns identifier of this object
*/
AliasMarker.prototype.getId = function() {
return this._id;
};
AliasMarker.prototype.setId = function(id) {
this._id = id;
};
/**
* Returns {@link Alias} data for this marker.
*
......@@ -62,15 +48,6 @@ AliasMarker.prototype.getCoordinates = function() {
+ this._aliasData.height / 2);
};
/**
* Function returning string marker type.
*
* @returns string marker type
*/
AliasMarker.prototype.getType = function() {
return "ALIAS";
};
AliasMarker.prototype.getModelId = function() {
return this.getAliasData().getModelId();
};
......
......@@ -14,7 +14,6 @@ function PointMarker(pointData, icon, map) {
element : ie,
map : map
});
this._id = pointData.getId();
this._pointData = pointData;
if (icon === null || icon === undefined) {
throw new Error("Icon must be not null");
......@@ -50,15 +49,6 @@ PointMarker.prototype.getCoordinates = function() {
return this._pointData.getPoint();
};
/**
* Function returning string marker type.
*
* @returns string marker type
*/
PointMarker.prototype.getType = function() {
return "POINT";
};
PointMarker.prototype.getModelId = function() {
return this.getPointData().getModelId();
};
......
......@@ -10,32 +10,21 @@ var IdentifiedElement = require('../data/IdentifiedElement');
function ReactionMarker(id, icon, reactionData, map) {
var ie = new IdentifiedElement(reactionData);
ie.setIcon(icon);
AbstractMarker.call(this, {
element : ie,
map : map
});
// id of the reaction to which marker is connected
this._id = id;
// data about the Reaction connected to the marker
this._reactionData = reactionData;
// google.maps.Marker object
this._marker = null;
this._init();
this.show();
this._init();
this.show();
}
ReactionMarker.prototype = Object.create(AbstractMarker.prototype);
ReactionMarker.prototype.constructor = ReactionMarker;
/**
* Returns identifier of this object.
*
* @returns identifier of this object
*/
ReactionMarker.prototype.getId = function() {
return this._id;
};
/**
* Returns {@link Reaction} data for this marker.
*
......@@ -64,15 +53,6 @@ ReactionMarker.prototype.getCoordinates = function() {
return new google.maps.Point(this._reactionData.getCenter().x, this._reactionData.getCenter().y);
};
/**
* Function returning string marker type.
*
* @returns string marker type
*/
ReactionMarker.prototype.getType = function() {
return "REACTION";
};
ReactionMarker.prototype.getModelId = function() {
return this.getReactionData().getModelId();
};
......
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