|
359 | 359 | return this.GmapUtil = {
|
360 | 360 | getLabelPositionPoint: function(anchor) {
|
361 | 361 | var xPos, yPos;
|
| 362 | + if (anchor === void 0) { |
| 363 | + return void 0; |
| 364 | + } |
362 | 365 | anchor = /^([\d\.]+)\s([\d\.]+)$/.exec(anchor);
|
363 | 366 | xPos = anchor[1];
|
364 | 367 | yPos = anchor[2];
|
|
558 | 561 | MarkerChildModel.include(directives.api.utils.GmapUtil);
|
559 | 562 |
|
560 | 563 | function MarkerChildModel(index, model, parentScope, gMap, $timeout, defaults, doClick, gMarkerManager) {
|
| 564 | + var self, |
| 565 | + _this = this; |
| 566 | + this.index = index; |
| 567 | + this.model = model; |
| 568 | + this.parentScope = parentScope; |
| 569 | + this.gMap = gMap; |
| 570 | + this.defaults = defaults; |
| 571 | + this.doClick = doClick; |
| 572 | + this.gMarkerManager = gMarkerManager; |
561 | 573 | this.watchDestroy = __bind(this.watchDestroy, this);
|
562 | 574 | this.setOptions = __bind(this.setOptions, this);
|
563 | 575 | this.setIcon = __bind(this.setIcon, this);
|
|
566 | 578 | this.maybeSetScopeValue = __bind(this.maybeSetScopeValue, this);
|
567 | 579 | this.createMarker = __bind(this.createMarker, this);
|
568 | 580 | this.setMyScope = __bind(this.setMyScope, this);
|
569 |
| - var _this = this; |
570 |
| - this.index = index; |
571 |
| - this.gMarkerManager = gMarkerManager; |
572 |
| - this.model = model; |
573 |
| - this.defaults = defaults; |
574 |
| - this.parentScope = parentScope; |
575 |
| - this.iconKey = parentScope.icon; |
576 |
| - this.coordsKey = parentScope.coords; |
577 |
| - this.clickKey = parentScope.click(); |
578 |
| - this.optionsKey = parentScope.options; |
579 |
| - this.myScope = parentScope.$new(false); |
580 |
| - this.myScope.model = model; |
581 |
| - this.gMap = gMap; |
582 |
| - this.setMyScope(model, void 0, true); |
583 |
| - this.createMarker(model); |
584 |
| - this.doClick = doClick; |
585 |
| - this.$log = directives.api.utils.Logger; |
| 581 | + self = this; |
| 582 | + this.iconKey = this.parentScope.icon; |
| 583 | + this.coordsKey = this.parentScope.coords; |
| 584 | + this.clickKey = this.parentScope.click(); |
| 585 | + this.labelContentKey = this.parentScope.labelContent; |
| 586 | + this.optionsKey = this.parentScope.options; |
| 587 | + this.labelOptionsKey = this.parentScope.labelOptions; |
| 588 | + this.myScope = this.parentScope.$new(false); |
| 589 | + this.myScope.model = this.model; |
| 590 | + this.setMyScope(this.model, void 0, true); |
| 591 | + this.createMarker(this.model); |
586 | 592 | this.myScope.$watch('model', function(newValue, oldValue) {
|
587 | 593 | if (newValue !== oldValue) {
|
588 | 594 | return _this.setMyScope(newValue, oldValue);
|
589 | 595 | }
|
590 | 596 | }, true);
|
| 597 | + this.$log = directives.api.utils.Logger; |
| 598 | + this.$log.info(self); |
591 | 599 | this.watchDestroy(this.myScope);
|
592 | 600 | }
|
593 | 601 |
|
|
600 | 608 | }
|
601 | 609 | this.maybeSetScopeValue('icon', model, oldModel, this.iconKey, this.evalModelHandle, isInit, this.setIcon);
|
602 | 610 | this.maybeSetScopeValue('coords', model, oldModel, this.coordsKey, this.evalModelHandle, isInit, this.setCoords);
|
| 611 | + this.maybeSetScopeValue('labelContent', model, oldModel, this.labelContentKey, this.evalModelHandle, isInit); |
603 | 612 | this.maybeSetScopeValue('click', model, oldModel, this.clickKey, this.evalModelHandle, isInit);
|
604 | 613 | return this.createMarker(model, oldModel, isInit);
|
605 | 614 | };
|
|
708 | 717 | }
|
709 | 718 | this.opts = this.createMarkerOptions(scope.coords, scope.icon, scope.options);
|
710 | 719 | delete this.gMarker;
|
711 |
| - this.gMarker = new google.maps.Marker(this.opts); |
| 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); |
| 725 | + } else { |
| 726 | + this.gMarker = new google.maps.Marker(this.opts); |
| 727 | + } |
712 | 728 | this.gMarkerManager.add(this.gMarker);
|
713 | 729 | return google.maps.event.addListener(this.gMarker, 'click', function() {
|
714 | 730 | if (_this.doClick && (_this.myScope.click != null)) {
|
|
1163 | 1179 |
|
1164 | 1180 | }).call(this);
|
1165 | 1181 |
|
1166 |
| -(function() { |
1167 |
| - var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, |
1168 |
| - __hasProp = {}.hasOwnProperty, |
1169 |
| - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; |
1170 |
| - |
1171 |
| - this.ngGmapModule("directives.api.models.parent", function() { |
1172 |
| - return this.MarkersLabelsParentModel = (function(_super) { |
1173 |
| - __extends(MarkersLabelsParentModel, _super); |
1174 |
| - |
1175 |
| - function MarkersLabelsParentModel(scope, element, attrs, ctrls, $timeout, $compile, $http, $templateCache, $interpolate) { |
1176 |
| - var self, |
1177 |
| - _this = this; |
1178 |
| - this.scope = scope; |
1179 |
| - this.element = element; |
1180 |
| - this.attrs = attrs; |
1181 |
| - this.ctrls = ctrls; |
1182 |
| - this.$timeout = $timeout; |
1183 |
| - this.$compile = $compile; |
1184 |
| - this.$http = $http; |
1185 |
| - this.$templateCache = $templateCache; |
1186 |
| - this.$interpolate = $interpolate; |
1187 |
| - this.watchForRebuild = __bind(this.watchForRebuild, this); |
1188 |
| - this.createChildMarkerLabels = __bind(this.createChildMarkerLabels, this); |
1189 |
| - self = this; |
1190 |
| - this.labels = []; |
1191 |
| - this.bigGulp = directives.api.utils.AsyncProcessor; |
1192 |
| - this.markersScope = this.ctrls[0].getMarkersScope(); |
1193 |
| - this.$log = directives.api.utils.Logger; |
1194 |
| - this.$log.info(self); |
1195 |
| - this.$timeout(function() { |
1196 |
| - _this.createChildMarkerLabels(); |
1197 |
| - return _this.watchForRebuild(_this.markersScope); |
1198 |
| - }, 50); |
1199 |
| - } |
1200 |
| - |
1201 |
| - MarkersLabelsParentModel.prototype.createChildMarkerLabels = function() { |
1202 |
| - var _this = this; |
1203 |
| - return this.bigGulp.handleLargeArray(this.markersScope.markerModels, function(marker) { |
1204 |
| - var childScope, content_key, label; |
1205 |
| - childScope = _this.scope.$new(false); |
1206 |
| - /* |
1207 |
| - markers-labels directive will specify a content attribute which will used |
1208 |
| - as the label content. This attribute is expected to exist in the marker model |
1209 |
| - |
1210 |
| - TODO: this is dirty, need a better way to handle this |
1211 |
| - */ |
1212 |
| - |
1213 |
| - content_key = childScope.labelContent; |
1214 |
| - if (marker.model[content_key]) { |
1215 |
| - childScope.labelContent = marker.model[content_key]; |
1216 |
| - label = new directives.api.models.child.MarkerLabelChildModel(marker.gMarker, childScope); |
1217 |
| - _this.labels.push(label); |
1218 |
| - return _this.scope.$on("$destroy", function() { |
1219 |
| - return label.destroy(); |
1220 |
| - }); |
1221 |
| - } else { |
1222 |
| - return _this.$log.info("marker content not specified: " + content_key); |
1223 |
| - } |
1224 |
| - }, (function() {}), function() { |
1225 |
| - return _this.scope.labelModels = _this.labels; |
1226 |
| - }); |
1227 |
| - }; |
1228 |
| - |
1229 |
| - MarkersLabelsParentModel.prototype.watchForRebuild = function(scope) { |
1230 |
| - var _this = this; |
1231 |
| - return scope.$on('markersRebuild', function(event, data) { |
1232 |
| - _this.$log.info('### REBUILD'); |
1233 |
| - _this.labels = []; |
1234 |
| - return _this.createChildMarkerLabels(); |
1235 |
| - }); |
1236 |
| - }; |
1237 |
| - |
1238 |
| - return MarkersLabelsParentModel; |
1239 |
| - |
1240 |
| - })(oo.BaseObject); |
1241 |
| - }); |
1242 |
| - |
1243 |
| -}).call(this); |
1244 |
| - |
1245 | 1182 | (function() {
|
1246 | 1183 | var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
|
1247 | 1184 | __hasProp = {}.hasOwnProperty,
|
|
1313 | 1250 | return _this.markersIndex++;
|
1314 | 1251 | }, (function() {}), function() {
|
1315 | 1252 | scope.markerModels = _this.markers;
|
1316 |
| - scope.$broadcast('markersRebuild'); |
1317 | 1253 | _this.gMarkerManager.draw();
|
1318 | 1254 | if (angular.isDefined(_this.attrs.fit) && (scope.fit != null) && scope.fit) {
|
1319 | 1255 | return _this.fit();
|
|
1836 | 1772 |
|
1837 | 1773 | }).call(this);
|
1838 | 1774 |
|
1839 |
| -(function() { |
1840 |
| - var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, |
1841 |
| - __hasProp = {}.hasOwnProperty, |
1842 |
| - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; |
1843 |
| - |
1844 |
| - this.ngGmapModule("directives.api", function() { |
1845 |
| - return this.Labels = (function(_super) { |
1846 |
| - __extends(Labels, _super); |
1847 |
| - |
1848 |
| - function Labels($timeout) { |
1849 |
| - this.link = __bind(this.link, this); |
1850 |
| - var self; |
1851 |
| - Labels.__super__.constructor.call(this, $timeout); |
1852 |
| - self = this; |
1853 |
| - this.require = ['^markers']; |
1854 |
| - this.template = '<span class="angular-google-map-markers-labels" ng-transclude></span>'; |
1855 |
| - this.scope.models = '=models'; |
1856 |
| - this.$log.info(this); |
1857 |
| - } |
1858 |
| - |
1859 |
| - Labels.prototype.link = function(scope, element, attrs, ctrl) { |
1860 |
| - return new directives.api.models.parent.MarkersLabelsParentModel(scope, element, attrs, ctrl, this.$timeout); |
1861 |
| - }; |
1862 |
| - |
1863 |
| - return Labels; |
1864 |
| - |
1865 |
| - })(directives.api.ILabel); |
1866 |
| - }); |
1867 |
| - |
1868 |
| -}).call(this); |
1869 |
| - |
1870 | 1775 | (function() {
|
1871 | 1776 | var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
|
1872 | 1777 | __hasProp = {}.hasOwnProperty,
|
@@ -1979,6 +1884,9 @@ not 1:1 in this setting.
|
1979 | 1884 | this.scope.doCluster = '=docluster';
|
1980 | 1885 | this.scope.clusterOptions = '=clusteroptions';
|
1981 | 1886 | this.scope.fit = '=fit';
|
| 1887 | + this.scope.labelContent = '=labelcontent'; |
| 1888 | + this.scope.labelAnchor = '@labelanchor'; |
| 1889 | + this.scope.labelClass = '@labelclass'; |
1982 | 1890 | this.$timeout = $timeout;
|
1983 | 1891 | this.$log.info(this);
|
1984 | 1892 | }
|
@@ -4866,49 +4774,6 @@ angular.module('google-maps').directive('markers', ['$timeout', function ($timeo
|
4866 | 4774 | angular.module('google-maps').directive('markerLabel', ['$log', '$timeout', function ($log, $timeout) {
|
4867 | 4775 | return new directives.api.Label($timeout);
|
4868 | 4776 | }]);
|
4869 |
| -;/**! |
4870 |
| - * The MIT License |
4871 |
| - * |
4872 |
| - * Copyright (c) 2010-2012 Google, Inc. http://angularjs.org |
4873 |
| - * |
4874 |
| - * Permission is hereby granted, free of charge, to any person obtaining a copy |
4875 |
| - * of this software and associated documentation files (the "Software"), to deal |
4876 |
| - * in the Software without restriction, including without limitation the rights |
4877 |
| - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
4878 |
| - * copies of the Software, and to permit persons to whom the Software is |
4879 |
| - * furnished to do so, subject to the following conditions: |
4880 |
| - * |
4881 |
| - * The above copyright notice and this permission notice shall be included in |
4882 |
| - * all copies or substantial portions of the Software. |
4883 |
| - * |
4884 |
| - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
4885 |
| - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
4886 |
| - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
4887 |
| - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
4888 |
| - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
4889 |
| - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
4890 |
| - * THE SOFTWARE. |
4891 |
| - * |
4892 |
| - * angular-google-maps |
4893 |
| - * https://github.com/nlaplante/angular-google-maps |
4894 |
| - * |
4895 |
| - * @authors Fernando Witzke, [email protected] |
4896 |
| - */ |
4897 |
| - |
4898 |
| -/** |
4899 |
| - * Markers labels directive |
4900 |
| - * |
4901 |
| - * This directive is used to create marker labels for the markers directive |
4902 |
| - * |
4903 |
| - * {attribute content required} content of the label |
4904 |
| - * {attribute anchor required} string that contains the x and y point position of the label |
4905 |
| - * {attribute class optional} class to DOM object |
4906 |
| - * {attribute style optional} style for the label |
4907 |
| - */ |
4908 |
| - |
4909 |
| -angular.module('google-maps').directive('markersLabels', ['$timeout', function ($timeout) { |
4910 |
| - return new directives.api.Labels($timeout); |
4911 |
| -}]); |
4912 | 4777 | ;/**!
|
4913 | 4778 | * The MIT License
|
4914 | 4779 | *
|
|
0 commit comments