|
385 | 385 | return opts;
|
386 | 386 | },
|
387 | 387 | createWindowOptions: function(gMarker, scope, content, defaults) {
|
388 |
| - return angular.extend({}, defaults, { |
389 |
| - content: content, |
390 |
| - position: angular.isObject(gMarker) ? gMarker.getPosition() : new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude) |
391 |
| - }); |
| 388 | + if ((content != null) && (defaults != null)) { |
| 389 | + return angular.extend({}, defaults, { |
| 390 | + content: content, |
| 391 | + position: angular.isObject(gMarker) ? gMarker.getPosition() : new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude) |
| 392 | + }); |
| 393 | + } |
392 | 394 | },
|
393 | 395 | defaultDelay: 50
|
394 | 396 | };
|
|
761 | 763 | return this.WindowChildModel = (function(_super) {
|
762 | 764 | __extends(WindowChildModel, _super);
|
763 | 765 |
|
764 |
| - function WindowChildModel(scope, opts, isIconVisibleOnClick, mapCtrl, markerCtrl, $http, $templateCache, $compile, needToManualDestroy) { |
| 766 | + WindowChildModel.include(directives.api.utils.GmapUtil); |
| 767 | + |
| 768 | + function WindowChildModel(scope, opts, isIconVisibleOnClick, mapCtrl, markerCtrl, $http, $templateCache, $compile, element, needToManualDestroy) { |
| 769 | + this.element = element; |
765 | 770 | if (needToManualDestroy == null) {
|
766 | 771 | needToManualDestroy = false;
|
767 | 772 | }
|
|
771 | 776 | this.handleClick = __bind(this.handleClick, this);
|
772 | 777 | this.watchCoords = __bind(this.watchCoords, this);
|
773 | 778 | this.watchShow = __bind(this.watchShow, this);
|
| 779 | + this.createGWin = __bind(this.createGWin, this); |
774 | 780 | this.scope = scope;
|
775 | 781 | this.opts = opts;
|
776 | 782 | this.mapCtrl = mapCtrl;
|
|
781 | 787 | this.$http = $http;
|
782 | 788 | this.$templateCache = $templateCache;
|
783 | 789 | this.$compile = $compile;
|
784 |
| - this.gWin = new google.maps.InfoWindow(opts); |
| 790 | + this.createGWin(); |
785 | 791 | if (this.markerCtrl != null) {
|
786 | 792 | this.markerCtrl.setClickable(true);
|
787 | 793 | }
|
|
792 | 798 | this.$log.info(this);
|
793 | 799 | }
|
794 | 800 |
|
| 801 | + WindowChildModel.prototype.createGWin = function(createOpts) { |
| 802 | + var _this = this; |
| 803 | + if (createOpts == null) { |
| 804 | + createOpts = false; |
| 805 | + } |
| 806 | + if ((this.gWin == null) && createOpts) { |
| 807 | + this.opts = this.markerCtrl != null ? this.createWindowOptions(this.markerCtrl, this.scope, this.element.html(), {}) : {}; |
| 808 | + } |
| 809 | + if ((this.opts != null) && this.gWin === void 0) { |
| 810 | + this.gWin = new google.maps.InfoWindow(this.opts); |
| 811 | + return google.maps.event.addListener(this.gWin, 'closeclick', function() { |
| 812 | + if (_this.markerCtrl != null) { |
| 813 | + _this.markerCtrl.setVisible(_this.initialMarkerVisibility); |
| 814 | + } |
| 815 | + if (_this.scope.closeClick != null) { |
| 816 | + return _this.scope.closeClick(); |
| 817 | + } |
| 818 | + }); |
| 819 | + } |
| 820 | + }; |
| 821 | + |
795 | 822 | WindowChildModel.prototype.watchShow = function() {
|
796 | 823 | var _this = this;
|
797 | 824 | return this.scope.$watch('show', function(newValue, oldValue) {
|
|
802 | 829 | return _this.hideWindow();
|
803 | 830 | }
|
804 | 831 | } else {
|
805 |
| - if (newValue && !_this.gWin.getMap()) { |
806 |
| - return _this.showWindow(); |
| 832 | + if (_this.gWin != null) { |
| 833 | + if (newValue && !_this.gWin.getMap()) { |
| 834 | + return _this.showWindow(); |
| 835 | + } |
807 | 836 | }
|
808 | 837 | }
|
809 | 838 | }, true);
|
|
821 | 850 | WindowChildModel.prototype.handleClick = function() {
|
822 | 851 | var _this = this;
|
823 | 852 | if (this.markerCtrl != null) {
|
824 |
| - google.maps.event.addListener(this.markerCtrl, 'click', function() { |
| 853 | + return google.maps.event.addListener(this.markerCtrl, 'click', function() { |
825 | 854 | var pos;
|
| 855 | + _this.createGWin(true); |
826 | 856 | pos = _this.markerCtrl.getPosition();
|
827 |
| - _this.gWin.setPosition(pos); |
828 |
| - _this.gWin.open(_this.mapCtrl); |
| 857 | + if (_this.gWin != null) { |
| 858 | + _this.gWin.setPosition(pos); |
| 859 | + _this.gWin.open(_this.mapCtrl); |
| 860 | + } |
829 | 861 | return _this.markerCtrl.setVisible(_this.isIconVisibleOnClick);
|
830 | 862 | });
|
831 | 863 | }
|
832 |
| - return google.maps.event.addListener(this.gWin, 'closeclick', function() { |
833 |
| - if (_this.markerCtrl != null) { |
834 |
| - _this.markerCtrl.setVisible(_this.initialMarkerVisibility); |
835 |
| - } |
836 |
| - if (_this.scope.closeClick != null) { |
837 |
| - return _this.scope.closeClick(); |
838 |
| - } |
839 |
| - }); |
840 | 864 | };
|
841 | 865 |
|
842 | 866 | WindowChildModel.prototype.showWindow = function() {
|
843 | 867 | var _this = this;
|
844 | 868 | if (this.scope.templateUrl) {
|
845 |
| - return this.$http.get(this.scope.templateUrl, { |
846 |
| - cache: this.$templateCache |
847 |
| - }).then(function(content) { |
848 |
| - var compiled, templateScope; |
849 |
| - templateScope = _this.scope.$new(); |
850 |
| - if (angular.isDefined(_this.scope.templateParameter)) { |
851 |
| - templateScope.parameter = _this.scope.templateParameter; |
852 |
| - } |
853 |
| - compiled = _this.$compile(content.data)(templateScope); |
854 |
| - _this.gWin.setContent(compiled.get(0)); |
855 |
| - return _this.gWin.open(_this.mapCtrl); |
856 |
| - }); |
| 869 | + if (this.gWin) { |
| 870 | + return this.$http.get(this.scope.templateUrl, { |
| 871 | + cache: this.$templateCache |
| 872 | + }).then(function(content) { |
| 873 | + var compiled, templateScope; |
| 874 | + templateScope = _this.scope.$new(); |
| 875 | + if (angular.isDefined(_this.scope.templateParameter)) { |
| 876 | + templateScope.parameter = _this.scope.templateParameter; |
| 877 | + } |
| 878 | + compiled = _this.$compile(content.data)(templateScope); |
| 879 | + _this.gWin.setContent(compiled.get(0)); |
| 880 | + return _this.gWin.open(_this.mapCtrl); |
| 881 | + }); |
| 882 | + } |
857 | 883 | } else {
|
858 |
| - return this.gWin.open(this.mapCtrl); |
| 884 | + if (this.gWin != null) { |
| 885 | + return this.gWin.open(this.mapCtrl); |
| 886 | + } |
859 | 887 | }
|
860 | 888 | };
|
861 | 889 |
|
862 | 890 | WindowChildModel.prototype.hideWindow = function() {
|
863 |
| - return this.gWin.close(); |
| 891 | + if (this.gWin != null) { |
| 892 | + return this.gWin.close(); |
| 893 | + } |
864 | 894 | };
|
865 | 895 |
|
866 | 896 | WindowChildModel.prototype.destroy = function() {
|
|
906 | 936 | };
|
907 | 937 |
|
908 | 938 | function IMarkerParentModel(scope, element, attrs, mapCtrl, $timeout) {
|
| 939 | + var self, |
| 940 | + _this = this; |
| 941 | + this.scope = scope; |
| 942 | + this.element = element; |
| 943 | + this.attrs = attrs; |
| 944 | + this.mapCtrl = mapCtrl; |
| 945 | + this.$timeout = $timeout; |
909 | 946 | this.linkInit = __bind(this.linkInit, this);
|
910 | 947 | this.onDestroy = __bind(this.onDestroy, this);
|
911 | 948 | this.onWatch = __bind(this.onWatch, this);
|
912 | 949 | this.watch = __bind(this.watch, this);
|
913 | 950 | this.validateScope = __bind(this.validateScope, this);
|
914 | 951 | this.onTimeOut = __bind(this.onTimeOut, this);
|
915 |
| - var self, |
916 |
| - _this = this; |
917 | 952 | self = this;
|
918 |
| - this.scope = scope; |
919 | 953 | this.$log = directives.api.utils.Logger;
|
920 |
| - this.element = element; |
921 |
| - this.attrs = attrs; |
922 | 954 | if (!this.validateScope(scope)) {
|
923 | 955 | return;
|
924 | 956 | }
|
925 | 957 | this.doClick = angular.isDefined(attrs.click);
|
926 |
| - this.mapCtrl = mapCtrl; |
927 |
| - this.$timeout = $timeout; |
928 | 958 | if (scope.options != null) {
|
929 | 959 | this.DEFAULTS = scope.options;
|
930 | 960 | }
|
|
1123 | 1153 | this.element.data('instance', this.gMarker);
|
1124 | 1154 | google.maps.event.addListener(this.gMarker, 'click', function() {
|
1125 | 1155 | if (_this.doClick && (scope.click != null)) {
|
1126 |
| - return $timeout(function() { |
| 1156 | + return _this.$timeout(function() { |
1127 | 1157 | return _this.scope.click();
|
1128 | 1158 | });
|
1129 | 1159 | }
|
@@ -1948,9 +1978,9 @@ not 1:1 in this setting.
|
1948 | 1978 | markerCtrl = ctrls.length > 1 && (ctrls[1] != null) ? ctrls[1].getMarker() : void 0;
|
1949 | 1979 | defaults = scope.options != null ? scope.options : {};
|
1950 | 1980 | hasScopeCoords = (scope != null) && (scope.coords != null) && (scope.coords.latitude != null) && (scope.coords.longitude != null);
|
1951 |
| - opts = (markerCtrl != null) && hasScopeCoords ? _this.createWindowOptions(markerCtrl, scope, element.html(), defaults) : {}; |
| 1981 | + opts = (markerCtrl != null) && hasScopeCoords ? _this.createWindowOptions(markerCtrl, scope, element.html(), defaults) : void 0; |
1952 | 1982 | if (mapCtrl != null) {
|
1953 |
| - window = new directives.api.models.child.WindowChildModel(scope, opts, isIconVisibleOnClick, mapCtrl, markerCtrl, _this.$http, _this.$templateCache, _this.$compile); |
| 1983 | + window = new directives.api.models.child.WindowChildModel(scope, opts, isIconVisibleOnClick, mapCtrl, markerCtrl, _this.$http, _this.$templateCache, _this.$compile, element); |
1954 | 1984 | }
|
1955 | 1985 | return scope.$on("$destroy", function() {
|
1956 | 1986 | return window.destroy();
|
|
0 commit comments