Skip to content
This repository was archived by the owner on Nov 30, 2018. It is now read-only.

Commit f0e584c

Browse files
committed
extracting set label options function
1 parent 2c5b62c commit f0e584c

File tree

3 files changed

+30
-14
lines changed

3 files changed

+30
-14
lines changed

dist/angular-google-maps.js

+17-7
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,8 @@
571571
this.doClick = doClick;
572572
this.gMarkerManager = gMarkerManager;
573573
this.watchDestroy = __bind(this.watchDestroy, this);
574+
this.setLabelOptions = __bind(this.setLabelOptions, this);
575+
this.isLabelDefined = __bind(this.isLabelDefined, this);
574576
this.setOptions = __bind(this.setOptions, this);
575577
this.setIcon = __bind(this.setIcon, this);
576578
this.setCoords = __bind(this.setCoords, this);
@@ -717,11 +719,8 @@
717719
}
718720
this.opts = this.createMarkerOptions(scope.coords, scope.icon, scope.options);
719721
delete this.gMarker;
720-
if (scope.labelContent != null) {
721-
this.opts.labelAnchor = this.getLabelPositionPoint(scope.labelAnchor);
722-
this.opts.labelClass = scope.labelClass;
723-
this.opts.labelContent = scope.labelContent;
724-
this.gMarker = new MarkerWithLabel(this.opts);
722+
if (this.isLabelDefined(scope)) {
723+
this.gMarker = new MarkerWithLabel(this.setLabelOptions(this.opts, scope));
725724
} else {
726725
this.gMarker = new google.maps.Marker(this.opts);
727726
}
@@ -733,6 +732,17 @@
733732
});
734733
};
735734

735+
MarkerChildModel.prototype.isLabelDefined = function(scope) {
736+
return scope.labelContent != null;
737+
};
738+
739+
MarkerChildModel.prototype.setLabelOptions = function(opts, scope) {
740+
opts.labelAnchor = this.getLabelPositionPoint(scope.labelAnchor);
741+
opts.labelClass = scope.labelClass;
742+
opts.labelContent = scope.labelContent;
743+
return opts;
744+
};
745+
736746
MarkerChildModel.prototype.watchDestroy = function(scope) {
737747
var _this = this;
738748
return scope.$on("$destroy", function() {
@@ -1249,11 +1259,11 @@
12491259
_this.markers.push(child);
12501260
return _this.markersIndex++;
12511261
}, (function() {}), function() {
1252-
scope.markerModels = _this.markers;
12531262
_this.gMarkerManager.draw();
12541263
if (angular.isDefined(_this.attrs.fit) && (scope.fit != null) && scope.fit) {
1255-
return _this.fit();
1264+
_this.fit();
12561265
}
1266+
return scope.markerModels = _this.markers;
12571267
});
12581268
};
12591269

0 commit comments

Comments
 (0)