diff --git a/frontend-js/src/main/js/map/marker/AbstractMarker.js b/frontend-js/src/main/js/map/marker/AbstractMarker.js index cd162bcbfaea1b32cde0a74a036bf118e55a2207..1f486f3d6b2146eff804cc679022c6d6192ee397 100644 --- a/frontend-js/src/main/js/map/marker/AbstractMarker.js +++ b/frontend-js/src/main/js/map/marker/AbstractMarker.js @@ -11,10 +11,8 @@ function AbstractMarker(icon, map) { // call super constructor ObjectWithListeners.call(this); - // icon of the marker - this._icon = icon; - // AbstractCustomMap where it's located - this._map = map; + this.setIcon(icon); + this.setCustomMap(map); } AbstractMarker.prototype = Object.create(ObjectWithListeners.prototype); @@ -29,6 +27,10 @@ AbstractMarker.prototype.getIcon = function() { return this._icon; }; +AbstractMarker.prototype.setIcon = function(icon) { + this._icon = icon; +}; + /** * Shows marker on the map. */ @@ -37,8 +39,7 @@ AbstractMarker.prototype.show = function() { logger.warn("Cannot show marker. Marker not initialized"); return; } - if (this.getGoogleMarker().getMap() !== undefined - && this.getGoogleMarker().getMap() !== null) { + if (this.getGoogleMarker().getMap() !== undefined && this.getGoogleMarker().getMap() !== null) { logger.warn("Marker is already shown"); } else { this.getGoogleMarker().setMap(this.getCustomMap().getGoogleMap()); @@ -50,8 +51,7 @@ AbstractMarker.prototype.hide = function() { logger.warn("Cannot hide marker. Marker not initialized"); return; } - if (this.getGoogleMarker().getMap() === null - || this.getGoogleMarker().getMap() === undefined) { + if (this.getGoogleMarker().getMap() === null || this.getGoogleMarker().getMap() === undefined) { logger.warn("Marker is already invisible"); } else { this.getGoogleMarker().setMap(null); @@ -68,6 +68,10 @@ AbstractMarker.prototype.getCustomMap = function() { return this._map; }; +AbstractMarker.prototype.setCustomMap = function(map) { + this._map = map;; +}; + /** * Returns {@link google.maps.Bounds bounds} of the marker (it's a single * point). @@ -91,14 +95,13 @@ AbstractMarker.prototype.getBounds = function() { * Set map where the marker should be visualized. * * @param map - * {@link google.maps.Map} where the marker should be visualized. + * {@link google.maps.Map} where the marker should be visualized. */ AbstractMarker.prototype.setMap = function(map) { if (this.getGoogleMarker() !== undefined) { this.getGoogleMarker().setMap(map); } else { - logger.warn("[" + this.constructor.name - + "] Cannot setup map. Marker wasn't initialized. Marker id: " + logger.warn("[" + this.constructor.name + "] Cannot setup map. Marker wasn't initialized. Marker id: " + this.getId()); } }; @@ -121,8 +124,7 @@ AbstractMarker.prototype.init = function() { var onclick = (function() { var aliasMarker = self; return function() { - aliasMarker.getCustomMap().getTopMap().openInfoWindowForMarker( - aliasMarker); + aliasMarker.getCustomMap().getTopMap().openInfoWindowForMarker(aliasMarker); }; })(); google.maps.event.addListener(this.getGoogleMarker(), 'click', onclick);