|
362 | 362 | return this.GmapUtil = {
|
363 | 363 | getLabelPositionPoint: function(anchor) {
|
364 | 364 | var xPos, yPos;
|
| 365 | + if (anchor === void 0) { |
| 366 | + return void 0; |
| 367 | + } |
365 | 368 | anchor = /^([\d\.]+)\s([\d\.]+)$/.exec(anchor);
|
366 | 369 | xPos = anchor[1];
|
367 | 370 | yPos = anchor[2];
|
|
507 | 510 | return self.markerLabel.setMap(theMap);
|
508 | 511 | });
|
509 | 512 | this.marker.setMap(this.marker.getMap());
|
510 |
| - this.$log = directives.api.utils.Logger; |
511 |
| - this.$log.info(this); |
512 | 513 | }
|
513 | 514 |
|
514 | 515 | MarkerLabelChildModel.prototype.getSharedCross = function(crossUrl) {
|
|
576 | 577 | MarkerChildModel.include(directives.api.utils.GmapUtil);
|
577 | 578 |
|
578 | 579 | function MarkerChildModel(index, model, parentScope, gMap, $timeout, defaults, doClick, gMarkerManager) {
|
| 580 | + var self, |
| 581 | + _this = this; |
| 582 | + this.index = index; |
| 583 | + this.model = model; |
| 584 | + this.parentScope = parentScope; |
| 585 | + this.gMap = gMap; |
| 586 | + this.defaults = defaults; |
| 587 | + this.doClick = doClick; |
| 588 | + this.gMarkerManager = gMarkerManager; |
579 | 589 | this.watchDestroy = __bind(this.watchDestroy, this);
|
| 590 | + this.setLabelOptions = __bind(this.setLabelOptions, this); |
| 591 | + this.isLabelDefined = __bind(this.isLabelDefined, this); |
580 | 592 | this.setOptions = __bind(this.setOptions, this);
|
581 | 593 | this.setIcon = __bind(this.setIcon, this);
|
582 | 594 | this.setCoords = __bind(this.setCoords, this);
|
583 | 595 | this.destroy = __bind(this.destroy, this);
|
584 | 596 | this.maybeSetScopeValue = __bind(this.maybeSetScopeValue, this);
|
585 | 597 | this.createMarker = __bind(this.createMarker, this);
|
586 | 598 | this.setMyScope = __bind(this.setMyScope, this);
|
587 |
| - var _this = this; |
588 |
| - this.index = index; |
589 |
| - this.gMarkerManager = gMarkerManager; |
590 |
| - this.model = model; |
591 |
| - this.defaults = defaults; |
592 |
| - this.parentScope = parentScope; |
593 |
| - this.iconKey = parentScope.icon; |
594 |
| - this.coordsKey = parentScope.coords; |
595 |
| - this.clickKey = parentScope.click(); |
596 |
| - this.optionsKey = parentScope.options; |
597 |
| - this.myScope = parentScope.$new(false); |
598 |
| - this.myScope.model = model; |
599 |
| - this.gMap = gMap; |
600 |
| - this.setMyScope(model, void 0, true); |
601 |
| - this.createMarker(model); |
602 |
| - this.doClick = doClick; |
603 |
| - this.$log = directives.api.utils.Logger; |
| 599 | + self = this; |
| 600 | + this.iconKey = this.parentScope.icon; |
| 601 | + this.coordsKey = this.parentScope.coords; |
| 602 | + this.clickKey = this.parentScope.click(); |
| 603 | + this.labelContentKey = this.parentScope.labelContent; |
| 604 | + this.optionsKey = this.parentScope.options; |
| 605 | + this.labelOptionsKey = this.parentScope.labelOptions; |
| 606 | + this.myScope = this.parentScope.$new(false); |
| 607 | + this.myScope.model = this.model; |
| 608 | + this.setMyScope(this.model, void 0, true); |
| 609 | + this.createMarker(this.model); |
604 | 610 | this.myScope.$watch('model', function(newValue, oldValue) {
|
605 | 611 | if (newValue !== oldValue) {
|
606 | 612 | return _this.setMyScope(newValue, oldValue);
|
607 | 613 | }
|
608 | 614 | }, true);
|
| 615 | + this.$log = directives.api.utils.Logger; |
| 616 | + this.$log.info(self); |
609 | 617 | this.watchDestroy(this.myScope);
|
610 | 618 | }
|
611 | 619 |
|
|
618 | 626 | }
|
619 | 627 | this.maybeSetScopeValue('icon', model, oldModel, this.iconKey, this.evalModelHandle, isInit, this.setIcon);
|
620 | 628 | this.maybeSetScopeValue('coords', model, oldModel, this.coordsKey, this.evalModelHandle, isInit, this.setCoords);
|
| 629 | + this.maybeSetScopeValue('labelContent', model, oldModel, this.labelContentKey, this.evalModelHandle, isInit); |
621 | 630 | this.maybeSetScopeValue('click', model, oldModel, this.clickKey, this.evalModelHandle, isInit);
|
622 | 631 | return this.createMarker(model, oldModel, isInit);
|
623 | 632 | };
|
|
726 | 735 | }
|
727 | 736 | this.opts = this.createMarkerOptions(scope.coords, scope.icon, scope.options);
|
728 | 737 | delete this.gMarker;
|
729 |
| - this.gMarker = new google.maps.Marker(this.opts); |
| 738 | + if (this.isLabelDefined(scope)) { |
| 739 | + this.gMarker = new MarkerWithLabel(this.setLabelOptions(this.opts, scope)); |
| 740 | + } else { |
| 741 | + this.gMarker = new google.maps.Marker(this.opts); |
| 742 | + } |
730 | 743 | this.gMarkerManager.add(this.gMarker);
|
731 | 744 | return google.maps.event.addListener(this.gMarker, 'click', function() {
|
732 | 745 | if (_this.doClick && (_this.myScope.click != null)) {
|
|
735 | 748 | });
|
736 | 749 | };
|
737 | 750 |
|
| 751 | + MarkerChildModel.prototype.isLabelDefined = function(scope) { |
| 752 | + return scope.labelContent != null; |
| 753 | + }; |
| 754 | + |
| 755 | + MarkerChildModel.prototype.setLabelOptions = function(opts, scope) { |
| 756 | + opts.labelAnchor = this.getLabelPositionPoint(scope.labelAnchor); |
| 757 | + opts.labelClass = scope.labelClass; |
| 758 | + opts.labelContent = scope.labelContent; |
| 759 | + return opts; |
| 760 | + }; |
| 761 | + |
738 | 762 | MarkerChildModel.prototype.watchDestroy = function(scope) {
|
739 | 763 | var _this = this;
|
740 | 764 | return scope.$on("$destroy", function() {
|
@@ -1916,6 +1940,9 @@ not 1:1 in this setting.
|
1916 | 1940 | this.scope.doCluster = '=docluster';
|
1917 | 1941 | this.scope.clusterOptions = '=clusteroptions';
|
1918 | 1942 | this.scope.fit = '=fit';
|
| 1943 | + this.scope.labelContent = '=labelcontent'; |
| 1944 | + this.scope.labelAnchor = '@labelanchor'; |
| 1945 | + this.scope.labelClass = '@labelclass'; |
1919 | 1946 | this.$timeout = $timeout;
|
1920 | 1947 | this.$log.info(this);
|
1921 | 1948 | }
|
|
0 commit comments