Commit 60b6cf2c authored by Piotr Gawron's avatar Piotr Gawron
Browse files

aliasMarker requires alias in constructor

parent 4fa8ac9e
......@@ -1469,23 +1469,6 @@ CustomMap.prototype.openInfoWindowForMarker = function(marker) {
var model = this.getSubmodelById(modelId);
logger.debug("Opening info window for " + marker.constructor.name + ": " + markerId + ", model: " + modelId);
var elementType = marker.getType();
if (marker instanceof AliasMarker) {
model.getModel().getAliasById(markerId).then(function(alias) {
// if we have only simple version of the data then ask server for more
// details
if (alias === null || alias === undefined || !alias.isComplete()) {
logger.debug("Accessing full alias: " + markerId);
var ids = [ [ modelId, markerId ] ];
ServerConnector.retreiveFullAliases(ids);
}
});
} else if (marker instanceof PointMarker) {
// no special treatment for points
} else if (marker instanceof ReactionMarker) {
// no special treatment for reactions
} else {
throw new Error("Unknown marker type: " + marker.constructor.name);
}
// open AliasInfoWindow in a right model
model._openInfoWindowForMarker(marker);
......
......@@ -14,10 +14,11 @@ function AliasMarker(id, icon, aliasData, map) {
this._aliasData = aliasData;
// google.maps.Marker object
this._marker = null;
if (this._aliasData !== null && this._aliasData !== undefined) {
this.init();
this.show();
if (this._aliasData === null || this._aliasData === undefined) {
throw new Error("Alias for marker must be defined");
}
this.init();
this.show();
}
AliasMarker.prototype = Object.create(AbstractMarker.prototype);
AliasMarker.prototype.constructor = AliasMarker;
......
......@@ -11,32 +11,19 @@ describe('AliasMarker', function() {
helper = new Helper();
});
it("Constructor", function() {
var aliasId = 97;
var map = helper.createAbstractCustomMap();
var alias = helper.createAlias(map);
var aliasMarker = new AliasMarker(aliasId, "empty.png", null, map);
var aliasMarker = new AliasMarker(alias.getId(), "empty.png", alias, map);
assert.equal(aliasId, aliasMarker.getId());
assert.equal(alias.getId(), aliasMarker.getId());
assert.equal(map, aliasMarker.getCustomMap());
assert.equal("empty.png", aliasMarker.getIcon());
assert.equal(null, aliasMarker.getAliasData());
assert.equal(null, aliasMarker._marker);
assert.equal(null, aliasMarker.getBounds());
});
it("init", function() {
var map = helper.createAbstractCustomMap();
var alias = helper.createAlias(map);
var aliasMarker = new AliasMarker(alias.getId(), "empty.png", null, map);
aliasMarker.setAliasData(alias);
aliasMarker.init();
assert.equal(alias, aliasMarker.getAliasData());
assert.ok(aliasMarker._marker);
assert.ok(aliasMarker.getBounds());
});
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment