diff --git a/frontend-js/src/main/js/map/AbstractCustomMap.js b/frontend-js/src/main/js/map/AbstractCustomMap.js index eecfc22814375770e013285f76a1e6d745bf9b73..9d43336a1efef32f7f498c2ec9a9d7b20372e6ec 100644 --- a/frontend-js/src/main/js/map/AbstractCustomMap.js +++ b/frontend-js/src/main/js/map/AbstractCustomMap.js @@ -595,7 +595,13 @@ AbstractCustomMap.prototype._showSelectedLayout = function(layoutId, index, leng return Promise.each(layoutAliases, function(layoutAlias) { if (layoutAlias.getModelId() === self.getId()) { return self.getModel().getAliasById(layoutAlias.getId()).then(function(aliasData) { - return AliasSurface.create(layoutAlias, aliasData, self, startX, endX); + return AliasSurface.create({ + overlayAlias : layoutAlias, + alias : aliasData, + map : self, + startX : startX, + endX : endX + }); }).then(function(overlay) { self.selectedLayoutOverlays[layoutId].push(overlay); }); diff --git a/frontend-js/src/main/js/map/surface/AliasSurface.js b/frontend-js/src/main/js/map/surface/AliasSurface.js index cafd56053a0d476d48eed3e2155b8f22efc0487c..1f5112879b6ee4983f68f09721ed3046cfb45c61 100644 --- a/frontend-js/src/main/js/map/surface/AliasSurface.js +++ b/frontend-js/src/main/js/map/surface/AliasSurface.js @@ -61,29 +61,32 @@ AliasSurface.prototype.setBoundsForAlias = function(startX, endX) { }; /** - * Creates {@link AliasSurface} from input data. + * Creates {@link AliasSurface}. * - * @param layoutAlias - * {@link LayoutAlias} for which overlay is created - * @param alias - * {@link Alias data} of the alias - * @param map - * {@link AbstractCustomMap} where overlay should be placed - * @param startX - * this is the ratio on OX axis that should be use as a starting point - * of the overlay. For instance when there are three layouts to - * visualize then + * @param params + * dict containing set of information required for surface creation: + * <li>overlayAlias - {@link LayoutAlias} for which overlay is created + * <li>alias - {@link Alias data} of the alias + * <li>map - {@link AbstractCustomMap} where overlay should be placed + * <li> startX - this is the ratio on OX axis that should be use as a + * starting point of the overlay. For instance when there are three + * layouts to visualize then * <ul> * <li>the first layout have startX=0.0; endX=0.33333</li> * <li>second layout have startX=0.33333; endX=0.66666</li> * <li>the last layout have startX=0.66666; endX=1.0</li> * </ul> - * @param endX - * this is the ratio on OX axis that should be use as a starting point - * of the overlay + * <li>endX this is the ratio on OX axis that should be use as a + * starting point of the overlay * @returns {AliasSurface} */ -AliasSurface.create = function(layoutAlias, alias, map, startX, endX) { +AliasSurface.create = function(params) { + var overlayAlias = params.overlayAlias; + var alias = params.alias; + var map = params.map; + var startX = params.startX; + var endX = params.endX; + var pointA = new google.maps.Point(alias.x + startX * alias.width, alias.y); var pointB = new google.maps.Point(alias.x + endX * alias.width, alias.y + alias.height); var latLngA = map.fromPointToLatLng(pointA); @@ -99,7 +102,7 @@ AliasSurface.create = function(layoutAlias, alias, map, startX, endX) { bounds : bounds }); - return functions.overlayToColor(layoutAlias).then(function(color) { + return functions.overlayToColor(overlayAlias).then(function(color) { rectangle.setOptions({ fillColor : color, }); diff --git a/frontend-js/src/test/js/map/surface/AliasSurface-test.js b/frontend-js/src/test/js/map/surface/AliasSurface-test.js index 7835fc84d13cc57fc612aba53ef052e4923b930a..793ea329ba1213bc23228c8503f3f2698f2b79fb 100644 --- a/frontend-js/src/test/js/map/surface/AliasSurface-test.js +++ b/frontend-js/src/test/js/map/surface/AliasSurface-test.js @@ -20,7 +20,13 @@ describe('AliasSurface', function() { var alias = helper.createAlias(map); var layoutAlias = helper.createLayoutAlias(alias); - return AliasSurface.create(layoutAlias, alias, map, 1, 2).then(function(result) { + return AliasSurface.create({ + overlayAlias : layoutAlias, + alias : alias, + map : map, + startX : 1, + endX : 2 + }).then(function(result) { assert.ok(result instanceof AliasSurface); assert.equal(logger.getWarnings.length, 0); }); @@ -57,7 +63,7 @@ describe('AliasSurface', function() { return result.onClickHandler(); }); }); - + }); });