Commit c98f7cc2 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

many identical icons for marker are resolved as single icon

parent 20c7c5ef
Pipeline #2587 passed with stage
in 43 seconds
...@@ -58,7 +58,15 @@ AbstractMarker.prototype.getIcon = function () { ...@@ -58,7 +58,15 @@ AbstractMarker.prototype.getIcon = function () {
} else if (icons.length === 1) { } else if (icons.length === 1) {
return icons[0]; return icons[0];
} else { } else {
return "marker/generic/search_green.png"; var result = icons[0];
//if we have many identical icons then return this specific icon
for (var i = 1; i < icons.length; i++) {
if (icons[i] !== result) {
return "marker/generic/search_green.png";
}
}
return result;
} }
}; };
......
"use strict"; "use strict";
/* exported logger */ require("../../mocha-config.js");
var ServerConnector = require('../../ServerConnector-mock');
var logger = require('../../logger'); var logger = require('../../logger');
...@@ -8,76 +10,94 @@ var AliasMarker = require('../../../../main/js/map/marker/AliasMarker'); ...@@ -8,76 +10,94 @@ var AliasMarker = require('../../../../main/js/map/marker/AliasMarker');
var IdentifiedElement = require('../../../../main/js/map/data/IdentifiedElement'); var IdentifiedElement = require('../../../../main/js/map/data/IdentifiedElement');
var assert = require('assert'); var assert = require('assert');
describe('AliasMarker', function() { describe('AliasMarker', function () {
it("Constructor", function() { it("Constructor", function () {
var map; var map, alias, marker;
var alias, marker; return ServerConnector.getProject().then(function (project) {
return ServerConnector.getProject().then(function(project) {
map = helper.createCustomMap(project); map = helper.createCustomMap(project);
return map.getModel().getAliasById(329171); return map.getModel().getAliasById(329171);
}).then(function(result) { }).then(function (result) {
alias = result; alias = result;
var identifiedElement = new IdentifiedElement(alias); var identifiedElement = new IdentifiedElement(alias);
identifiedElement.setIcon("empty.png"); identifiedElement.setIcon("empty.png");
marker = new AliasMarker({ marker = new AliasMarker({
element : identifiedElement, element: identifiedElement,
map : map map: map
}); });
assert.equal(alias.getId(), marker.getId()); assert.equal(alias.getId(), marker.getId());
assert.equal(map, marker.getCustomMap()); assert.equal(map, marker.getCustomMap());
assert.equal("empty.png", marker.getIcon()); assert.equal("empty.png", marker.getIcon());
return marker.init(); return marker.init();
}).then(function() { }).then(function () {
assert.equal(alias, marker.getAliasData()); assert.equal(alias, marker.getAliasData());
assert.ok(marker._marker); assert.ok(marker._marker);
assert.ok(marker.getBounds()); assert.ok(marker.getBounds());
assert.equal(0, logger.getWarnings().length);
});
});
it("getIcon", function () {
var map = helper.createCustomMap();
var element = helper.createAlias(map);
var marker = new AliasMarker({
element: new IdentifiedElement(element),
map: map
}); });
var icon = "test.png";
marker.addIcon("test.png");
assert.equal(icon, marker.getIcon());
marker.addIcon("test.png");
assert.equal(icon, marker.getIcon());
marker.removeIcon("test.png");
assert.equal(icon, marker.getIcon());
marker.removeIcon("test.png");
assert.equal(undefined, marker.getIcon());
}); });
it("click on marker", function() { it("click on marker", function () {
var map; var map;
var marker; var marker;
return ServerConnector.getProject().then(function(project) { return ServerConnector.getProject().then(function (project) {
map = helper.createCustomMap(project); map = helper.createCustomMap(project);
return map.getModel().getAliasById(329171); return map.getModel().getAliasById(329171);
}).then(function(alias) { }).then(function (alias) {
var identifiedElement = new IdentifiedElement(alias); var identifiedElement = new IdentifiedElement(alias);
marker = new AliasMarker({ marker = new AliasMarker({
element : identifiedElement, element: identifiedElement,
map : map map: map
}); });
return marker.init(); return marker.init();
}).then(function() { }).then(function () {
return google.maps.event.trigger(marker.getGoogleMarker(), "click"); return google.maps.event.trigger(marker.getGoogleMarker(), "click");
}); });
}); });
it("click on marker when chemical is not available", function() { it("click on marker when chemical is not available", function () {
var projectId = "complex_model_with_submaps"; var projectId = "complex_model_with_submaps";
helper.setUrl("http://test/?id=" + projectId); helper.setUrl("http://test/?id=" + projectId);
var map; var map;
var marker; var marker;
return ServerConnector.getProject(projectId).then(function(project) { return ServerConnector.getProject(projectId).then(function (project) {
map = helper.createCustomMap(project); map = helper.createCustomMap(project);
var ov = helper.createChemicalDbOverlay(map); var ov = helper.createChemicalDbOverlay(map);
ov.setAllowGeneralSearch(false); ov.setAllowGeneralSearch(false);
ov.setAllowSearchById(false); ov.setAllowSearchById(false);
return map.getModel().getAliasById(345334); return map.getModel().getAliasById(345334);
}).then(function(alias) { }).then(function (alias) {
var identifiedElement = new IdentifiedElement(alias); var identifiedElement = new IdentifiedElement(alias);
marker = new AliasMarker({ marker = new AliasMarker({
element : identifiedElement, element: identifiedElement,
map : map map: map
}); });
return marker.init(); return marker.init();
}).then(function() { }).then(function () {
return google.maps.event.trigger(marker.getGoogleMarker(), "click"); return google.maps.event.trigger(marker.getGoogleMarker(), "click");
}); });
......
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