Skip to content

Commit 9d6eae9

Browse files
committed
issue allenhwkim#450, changed all console.log to .log
1 parent fb29246 commit 9d6eae9

21 files changed

+85
-69
lines changed

app.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
11
angular.module('ngMap', []);
2+
angular.module('ngMap').config([
3+
'$compileProvider',
4+
'$logProvider',
5+
function ($compileProvider, $logProvider) {
6+
var debugMode = !!window.location.search.match(/[\?\&]debug=1/);
7+
$logProvider.debugEnabled(debugMode);
8+
$compileProvider.debugInfoEnabled(debugMode);
9+
}
10+
]);

controllers/map-controller.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44
*/
55
(function() {
66
'use strict';
7-
var Attr2MapOptions;
87

98
var __MapController = function(
10-
$scope, $element, $attrs, $parse, _Attr2MapOptions_, NgMap, NgMapPool
9+
$scope, $element, $attrs, $parse, $log, Attr2MapOptions, NgMap, NgMapPool
1110
) {
12-
Attr2MapOptions = _Attr2MapOptions_;
1311
var vm = this;
1412

1513
vm.mapOptions; /** @memberof __MapController */
@@ -55,7 +53,7 @@
5553
var objs = obj.map[groupName];
5654
for (var name in objs) {
5755
if (objs[name] === obj) {
58-
console.log('Deleting', groupName, obj);
56+
$log.debug('Deleting', groupName, obj);
5957
google.maps.event.clearInstanceListeners(obj);
6058
delete objs[name];
6159
}
@@ -145,7 +143,7 @@
145143
var options = Attr2MapOptions.getOptions(filtered);
146144
var controlOptions = Attr2MapOptions.getControlOptions(filtered);
147145
mapOptions = angular.extend(options, controlOptions);
148-
console.log('map options', mapOptions);
146+
$log.debug('map options', mapOptions);
149147

150148
for (var group in lazyInitMap) {
151149
var groupMembers = lazyInitMap[group]; //e.g. markers
@@ -218,8 +216,8 @@
218216
var controlOptions = Attr2MapOptions.getControlOptions(filtered);
219217
var mapOptions = angular.extend(options, controlOptions);
220218
var mapEvents = Attr2MapOptions.getEvents($scope, filtered);
221-
console.log('ng-map Options', mapOptions);
222-
Object.keys(mapEvents).length && console.log('ng-map Events', mapEvents);
219+
$log.debug('ng-map Options', mapOptions);
220+
Object.keys(mapEvents).length && $log.debug('ng-map Events', mapEvents);
223221

224222
vm.mapOptions = mapOptions;
225223
vm.mapEvents = mapEvents;
@@ -243,7 +241,7 @@
243241
}; // __MapController
244242

245243
__MapController.$inject = [
246-
'$scope', '$element', '$attrs', '$parse', 'Attr2MapOptions', 'NgMap', 'NgMapPool'
244+
'$scope', '$element', '$attrs', '$parse', '$log', 'Attr2MapOptions', 'NgMap', 'NgMapPool'
247245
];
248246
angular.module('ngMap').controller('__MapController', __MapController);
249247
})();

directives/bicycling-layer.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
(function() {
1717
'use strict';
18-
var parser;
18+
var $log, parser;
1919

2020
var linkFunc = function(scope, element, attrs, mapController) {
2121
mapController = mapController[0]||mapController[1];
@@ -24,7 +24,7 @@
2424
var options = parser.getOptions(filtered, {scope: scope});
2525
var events = parser.getEvents(scope, filtered);
2626

27-
console.log('bicycling-layer options', options, 'events', events);
27+
$log.debug('bicycling-layer options', options, 'events', events);
2828

2929
var layer = getLayer(options, events);
3030
mapController.addObject('bicyclingLayers', layer);
@@ -42,15 +42,15 @@
4242
return layer;
4343
};
4444

45-
var bicyclingLayer= function(Attr2MapOptions) {
46-
parser = Attr2MapOptions;
45+
var bicyclingLayer= function(_$log_, Attr2MapOptions) {
46+
$log = _$log_, parser = Attr2MapOptions;
4747
return {
4848
restrict: 'E',
4949
require: ['?^map','?^ngMap'],
5050
link: linkFunc
5151
};
5252
};
53-
bicyclingLayer.$inject = ['Attr2MapOptions'];
53+
bicyclingLayer.$inject = ['$log', 'Attr2MapOptions'];
5454

5555
angular.module('ngMap').directive('bicyclingLayer', bicyclingLayer);
5656
})();

directives/custom-marker.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
/* global document */
2828
(function() {
2929
'use strict';
30-
var parser, $timeout, $compile, NgMap;
30+
var parser, $timeout, $compile, $log, NgMap;
3131

3232
var CustomMarker = function(options) {
3333
options = options || {};
@@ -121,7 +121,7 @@
121121
};
122122

123123
var linkFunc = function(orgHtml, varsToWatch) {
124-
//console.log('orgHtml', orgHtml, 'varsToWatch', varsToWatch);
124+
$log.debug('orgHtml', orgHtml, 'varsToWatch', varsToWatch);
125125

126126
return function(scope, element, attrs, mapController) {
127127
mapController = mapController[0]||mapController[1];
@@ -135,7 +135,7 @@
135135
* build a custom marker element
136136
*/
137137
element[0].style.display = 'none';
138-
console.log("custom-marker options", options);
138+
$log.debug("custom-marker options", options);
139139
var customMarker = new CustomMarker(options);
140140

141141
$timeout(function() { //apply contents, class, and location after it is compiled
@@ -147,7 +147,7 @@
147147
var classNames = element[0].firstElementChild.className;
148148
customMarker.addClass('custom-marker');
149149
customMarker.addClass(classNames);
150-
console.log('customMarker', customMarker, 'classNames', classNames);
150+
$log.debug('customMarker', customMarker, 'classNames', classNames);
151151

152152
if (!(options.position instanceof google.maps.LatLng)) {
153153
NgMap.getGeoLocation(options.position).then(
@@ -158,7 +158,7 @@
158158
}
159159
});
160160

161-
console.log("custom-marker events", "events");
161+
$log.debug("custom-marker events", "events");
162162
for (var eventName in events) { /* jshint ignore:line */
163163
google.maps.event.addDomListener(
164164
customMarker.el, eventName, events[eventName]);
@@ -178,11 +178,12 @@
178178

179179

180180
var customMarkerDirective = function(
181-
_$timeout_, _$compile_, Attr2MapOptions, _NgMap_
181+
_$timeout_, _$compile_, _$log_, Attr2MapOptions, _NgMap_
182182
) {
183183
parser = Attr2MapOptions;
184184
$timeout = _$timeout_;
185185
$compile = _$compile_;
186+
$log = _$log_;
186187
NgMap = _NgMap_;
187188

188189
return {
@@ -209,7 +210,7 @@
209210
}; // return
210211
};// function
211212
customMarkerDirective.$inject =
212-
['$timeout', '$compile', 'Attr2MapOptions', 'NgMap'];
213+
['$timeout', '$compile', '$log', 'Attr2MapOptions', 'NgMap'];
213214

214215
angular.module('ngMap').directive('customMarker', customMarkerDirective);
215216
})();

directives/directions.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
/* global document */
2929
(function() {
3030
'use strict';
31-
var NgMap, $timeout, NavigatorGeolocation;
31+
var NgMap, $timeout, $log, NavigatorGeolocation;
3232

3333
var getDirectionsRenderer = function(options, events) {
3434
if (options.panel) {
@@ -92,10 +92,11 @@
9292
};
9393

9494
var directions = function(
95-
Attr2MapOptions, _$timeout_, _NavigatorGeolocation_, _NgMap_) {
95+
Attr2MapOptions, _$timeout_, _$log_, _NavigatorGeolocation_, _NgMap_) {
9696
var parser = Attr2MapOptions;
9797
NgMap = _NgMap_;
9898
$timeout = _$timeout_;
99+
$log = _$log_;
99100
NavigatorGeolocation = _NavigatorGeolocation_;
100101

101102
var linkFunc = function(scope, element, attrs, mapController) {
@@ -117,12 +118,12 @@
117118
$timeout(function(){
118119
var panel =
119120
document.getElementById(val) || document.querySelector(val);
120-
console.log('setting ', attrName, 'with value', panel);
121+
$log.debug('setting ', attrName, 'with value', panel);
121122
panel && renderer.setPanel(panel);
122123
});
123124
} else if (options[attrName] !== val) { //apply only if changed
124125
var optionValue = parser.toOptionValue(val, {key: attrName});
125-
console.log('setting ', attrName, 'with value', optionValue);
126+
$log.debug('setting ', attrName, 'with value', optionValue);
126127
options[attrName] = optionValue;
127128
updateRoute(renderer, options);
128129
}
@@ -145,7 +146,7 @@
145146
};
146147
}; // var directions
147148
directions.$inject =
148-
['Attr2MapOptions', '$timeout', 'NavigatorGeolocation', 'NgMap'];
149+
['Attr2MapOptions', '$timeout', '$log', 'NavigatorGeolocation', 'NgMap'];
149150

150151
angular.module('ngMap').directive('directions', directions);
151152
})();

directives/fusion-tables-layer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
'use strict';
1919

2020
angular.module('ngMap').directive('fusionTablesLayer', [
21-
'Attr2MapOptions', function(Attr2MapOptions) {
21+
'$log', 'Attr2MapOptions', function($log, Attr2MapOptions) {
2222
var parser = Attr2MapOptions;
2323

2424
var getLayer = function(options, events) {
@@ -41,7 +41,7 @@
4141
var filtered = parser.filter(attrs);
4242
var options = parser.getOptions(filtered, {scope: scope});
4343
var events = parser.getEvents(scope, filtered, events);
44-
console.log('fusion-tables-layer options', options, 'events', events);
44+
$log.debug('fusion-tables-layer options', options, 'events', events);
4545

4646
var layer = getLayer(options, events);
4747
mapController.addObject('fusionTablesLayers', layer);

directives/heatmap-layer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
'use strict';
1717

1818
angular.module('ngMap').directive('heatmapLayer', [
19-
'Attr2MapOptions', '$window', function(Attr2MapOptions, $window) {
19+
'Attr2MapOptions', '$window', '$log', function(Attr2MapOptions, $window, $log) {
2020
var parser = Attr2MapOptions;
2121
return {
2222
restrict: 'E',
@@ -43,7 +43,7 @@
4343
* set events
4444
*/
4545
var events = parser.getEvents(scope, filtered);
46-
console.log('heatmap-layer options', layer, 'events', events);
46+
$log.debug('heatmap-layer options', layer, 'events', events);
4747

4848
mapController.addObject('heatmapLayers', layer);
4949
}

directives/kml-layer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
'use strict';
3030

3131
angular.module('ngMap').directive('kmlLayer', [
32-
'Attr2MapOptions', function(Attr2MapOptions) {
32+
'$log', 'Attr2MapOptions', function($log, Attr2MapOptions) {
3333
var parser = Attr2MapOptions;
3434

3535
var getKmlLayer = function(options, events) {
@@ -51,7 +51,7 @@
5151
var filtered = parser.filter(attrs);
5252
var options = parser.getOptions(filtered, {scope: scope});
5353
var events = parser.getEvents(scope, filtered);
54-
console.log('kml-layer options', options, 'events', events);
54+
$log.debug('kml-layer options', options, 'events', events);
5555

5656
var kmlLayer = getKmlLayer(options, events);
5757
mapController.addObject('kmlLayers', kmlLayer);

directives/map-data.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
'use strict';
2121

2222
angular.module('ngMap').directive('mapData', [
23-
'Attr2MapOptions', 'NgMap', function(Attr2MapOptions, NgMap) {
23+
'$log', 'Attr2MapOptions', 'NgMap', function($log, Attr2MapOptions, NgMap) {
2424
var parser = Attr2MapOptions;
2525
return {
2626
restrict: 'E',
@@ -31,7 +31,7 @@
3131
var options = parser.getOptions(filtered, {scope: scope});
3232
var events = parser.getEvents(scope, filtered, events);
3333

34-
console.log('map-data options', options);
34+
$log.debug('map-data options', options);
3535
NgMap.getMap().then(function(map) {
3636
//options
3737
for (var key in options) {

directives/map-lazy-load.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@
3636
/* global window, document */
3737
(function() {
3838
'use strict';
39-
var $timeout, $compile, src, savedHtml;
39+
var $timeout, $compile, $log, src, savedHtml;
4040

4141
var preLinkFunc = function(scope, element, attrs) {
4242
var mapsUrl = attrs.mapLazyLoadParams || attrs.mapLazyLoad;
4343

4444
window.lazyLoadCallback = function() {
45-
console.log('Google maps script loaded:', mapsUrl);
45+
$log.debug('Google maps script loaded:', mapsUrl);
4646
$timeout(function() { /* give some time to load */
4747
element.html(savedHtml);
4848
$compile(element.contents())(scope);
@@ -51,7 +51,7 @@
5151

5252
if(window.google === undefined || window.google.maps === undefined) {
5353
var scriptEl = document.createElement('script');
54-
console.log('Prelinking script loaded,' + src);
54+
$log.debug('Prelinking script loaded,' + src);
5555

5656
scriptEl.src = mapsUrl +
5757
(mapsUrl.indexOf('?') > -1 ? '&' : '?') +
@@ -68,7 +68,7 @@
6868

6969
var compileFunc = function(tElement, tAttrs) {
7070

71-
(!tAttrs.mapLazyLoad) && console.error('requires src with map-lazy-load');
71+
(!tAttrs.mapLazyLoad) && $log.error('requires src with map-lazy-load');
7272
savedHtml = tElement.html();
7373
src = tAttrs.mapLazyLoad;
7474

@@ -86,13 +86,13 @@
8686
};
8787
};
8888

89-
var mapLazyLoad = function(_$compile_, _$timeout_) {
90-
$compile = _$compile_, $timeout = _$timeout_;
89+
var mapLazyLoad = function(_$compile_, _$timeout_, _$log_) {
90+
$compile = _$compile_, $timeout = _$timeout_, $log = _$log_;
9191
return {
9292
compile: compileFunc
9393
};
9494
};
95-
mapLazyLoad.$inject = ['$compile','$timeout'];
95+
mapLazyLoad.$inject = ['$compile','$timeout', '$log'];
9696

9797
angular.module('ngMap').directive('mapLazyLoad', mapLazyLoad);
9898
})();

0 commit comments

Comments
 (0)