Skip to content

Commit 7760b3b

Browse files
author
Andrew Fink
committed
Merge pull request #2 from azavea/feature/ngdocs
Add initial docstrings
2 parents 1d98d47 + 07c9c96 commit 7760b3b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+13676
-42
lines changed

bower.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"leaflet": ">=0.7.7"
2323
},
2424
"devDependencies": {
25+
"angular-animate": ">=1.2.0",
2526
"angular-mocks": ">=1.2.0",
2627
"angular-scenario": ">=1.2.0"
2728
}

dist/azavea-ng-leaflet.js

Lines changed: 152 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@
88

99
})(angular);
1010

11+
/**
12+
* @ngdoc directive
13+
* @name az.leaflet.directive:azLeafletCenter
14+
* @restrict 'E'
15+
* @requires az.leaflet.directive:azLeaflet
16+
* @scope
17+
*
18+
* @description
19+
* Helper directive to two-way bind the leaflet map center/zoom, must be nested within an
20+
* {@link az.leaflet.directive:azLeaflet azLeaflet} directive
21+
*
22+
* @param {L.LatLng} center - Center of map, watched for changes
23+
* @param {Integer} zoom - Zoom level of map, watched for changes
24+
* @param {L.ZoomPanOptions=} options - Zoom/Pan options object to use to control the zoom/pan
25+
*/
1126
(function () {
1227
'use strict';
1328

@@ -55,6 +70,19 @@
5570

5671
})();
5772

73+
/**
74+
* @ngdoc service
75+
* @name az.leaflet.factory:AZLeafletComponentFactory
76+
*
77+
* @description
78+
* This is purely a helper method to generate new Angular Directive Definition Objects for
79+
* new azLeaflet directives that the user may want to create.
80+
*
81+
* TODO: Document the onMapReady property of the DDO
82+
*
83+
* @param {Object} directive - Directive Definition Object that extends the
84+
* AZLeafletComponentFactory defaults
85+
*/
5886
(function () {
5987
'use strict';
6088

@@ -90,6 +118,15 @@
90118
.factory('AZLeafletComponentFactory', LeafletComponent);
91119
})();
92120

121+
/**
122+
* @ngdoc controller
123+
* @name az.leaflet.controller:AZLeafletController
124+
*
125+
* @description
126+
* The controller for the AZLeaflet directive, which provides direct access to the
127+
* L.map object instantiated for that map. Should only be accessed in child directives
128+
* via the link function's `controller` argument.
129+
*/
93130
(function () {
94131
'use strict';
95132

@@ -110,7 +147,13 @@
110147
}
111148

112149
/**
150+
* @ngdoc function
151+
* @name az.leaflet.controller:AZLeafletController#getMap
152+
* @methodOf az.leaflet.controller:AZLeafletController
153+
*
154+
* @description
113155
* Get a promise reference to the map object created by the directive
156+
*
114157
* @return {Promise} Resolves with an L.map object
115158
*/
116159
function getMap() {
@@ -141,18 +184,24 @@
141184
angular.module('az.leaflet')
142185
.controller('AZLeafletController', LeafletController);
143186
})();
187+
/**
188+
* @ngdoc service
189+
* @name az.leaflet.service:AZLeafletData
190+
*
191+
* @description
192+
* Handles storage and retrieval of {@link http://leafletjs.com/reference.html#map-class L.map}
193+
* objects instantiated via {@link az.leaflet.directive:azLeaflet azLeaflet} directive
194+
*/
144195
(function () {
145196
'use strict';
146197

147-
/**
148-
* LeafletData stores references to L.map objects instantiated by the az-leaflet directive.
149-
*/
150198
/*@ngInject*/
151199
LeafletData.$inject = ["$log", "$q"];
152200
function LeafletData($log, $q) {
153201
var maps = {};
154202

155203
var module = {
204+
156205
getMap: getMap,
157206
setMap: setMap,
158207
deleteMap: deleteMap
@@ -223,9 +272,16 @@
223272
}
224273

225274
/**
226-
* Save map to LeafletData with the given id
227-
* @param {L.map} map Map object to save
228-
* @param {string} scopeId Unique string key to save the map with
275+
* @ngdoc function
276+
* @name az.leaflet.service:AZLeafletData#setMap
277+
* @methodOf az.leaflet.service:AZLeafletData
278+
*
279+
* @description
280+
* Save map to AZLeafletData with the given id
281+
*
282+
* @param {L.map} map - Map object to save
283+
* @param {String} scopeId - Unique string key to save the map with, use this id to retrieve
284+
* later with getMap()
229285
*/
230286
function setMap(map, scopeId) {
231287
var defer = getUnresolvedDefer(maps, scopeId);
@@ -234,17 +290,36 @@
234290
}
235291

236292
/**
237-
* Get map with the given id. If only one map is saved to LeafletData, the id can be omitted
238-
* and getMap will return the only map object it is caching.
293+
* @ngdoc function
294+
* @name az.leaflet.service:AZLeafletData#getMap
295+
* @methodOf az.leaflet.service:AZLeafletData
239296
*
240-
* @param {string} scopeId Optional. Id of map to retrieve from LeafletData
241-
* @return {promise} resolved with the ol.Map object
297+
* @description
298+
* Get map with the given id. If only one map is saved to AZLeafletData, the id can be
299+
* omitted and getMap will return the only map object it is caching.
300+
*
301+
* @param {String=} scopeId - Id of map to retrieve from AZLeafletData. Optional if
302+
* there is only one initialized map.
303+
* @return {Promise} Resolves with the requested L.map object
242304
*/
243305
function getMap(scopeId) {
244306
var defer = getDefer(maps, scopeId);
245307
return defer.promise;
246308
}
247309

310+
/**
311+
* @ngdoc function
312+
* @name az.leaflet.service:AZLeafletData#deleteMap
313+
* @methodOf az.leaflet.service:AZLeafletData
314+
*
315+
* @description
316+
* Remove the map with id from the AZLeafletData cache.
317+
*
318+
* DOES NOT remove the map from the DOM or do any other associated cleanup tasks
319+
*
320+
* @param {String=} scopeId - Id of map to delete from AZLeafletData. Optional if
321+
* there is only one initialized map.
322+
*/
248323
function deleteMap(scopeId) {
249324
var id = obtainEffectiveMapId(maps, scopeId);
250325
$log.info(maps, id);
@@ -255,14 +330,19 @@
255330
angular.module('az.leaflet')
256331
.service('AZLeafletData', LeafletData);
257332
})();
333+
/**
334+
* @ngdoc object
335+
* @name az.leaflet.provider:AZLeafletDefaultsProvider
336+
*
337+
* @description
338+
*
339+
* AZLeafletDefaults provides the default
340+
* {@link http://leafletjs.com/reference.html#map-options L.MapOptions} object for each new map
341+
* that is instantiated via the directive
342+
*/
258343
(function() {
259344
'use strict';
260345

261-
/**
262-
* Provides defaults for new maps created using the azLeaflet directive.
263-
*
264-
* Defaults can be changed at config time via LeafletDefaults.setDefaults()
265-
*/
266346
/*@ngInject*/
267347
function LeafletDefaultsProvider() {
268348
var svc = this;
@@ -273,16 +353,35 @@
273353
};
274354

275355
/**
276-
* Update defaults by merging user-set defaults into defaults object
277-
* @param {LeafletDefaults} newDefaults
356+
* @ngdoc function
357+
* @name az.leaflet.provider:AZLeafletDefaultsProvider#setDefaults
358+
* @methodOf az.leaflet.provider:AZLeafletDefaultsProvider
359+
*
360+
* @description
361+
* Extend the default AZLeafletDefaults object
362+
*
363+
* Default object is:
364+
* ```
365+
* var defaults = {
366+
* center: [0,0],
367+
* zoom: 1,
368+
* crs: L.CRS.EPSG3857
369+
* };
370+
* ```
371+
*
372+
* @param {L.MapOptions} newDefaults - L.MapOptions object to extend the built-in
373+
* defaults with
278374
*/
279375
svc.setDefaults = function (newDefaults) {
280376
angular.merge(defaults, newDefaults);
281377
};
282378

283379
svc.$get = LeafletDefaults;
284380

285-
/** Read-only wrapper around defaults */
381+
/**
382+
* @ngdoc service
383+
* @name az.leaflet.service:AZLeafletDefaults
384+
*/
286385
/*@ngInject*/
287386
function LeafletDefaults() {
288387
var module = {
@@ -291,8 +390,11 @@
291390
return module;
292391

293392
/**
294-
* Return a copy of the current set of defaults
295-
* @return {LeafletDefaults}
393+
* @ngdoc function
394+
* @name az.leaflet.service:AZLeafletDefaults#get
395+
* @methodOf az.leaflet.service:AZLeafletDefaults
396+
*
397+
* @return {L.MapOptions} Shallow copy of the current AZLeafletDefaults
296398
*/
297399
function get() {
298400
return angular.extend({}, defaults);
@@ -303,6 +405,25 @@
303405
angular.module('az.leaflet')
304406
.provider('AZLeafletDefaults', LeafletDefaultsProvider);
305407
})();
408+
/**
409+
* @ngdoc directive
410+
* @name az.leaflet.directive:azLeaflet
411+
* @restrict 'E'
412+
* @scope
413+
*
414+
* @description
415+
* Instantiate a new leaflet map on the element, with options, which are not watched for changes
416+
*
417+
* A class azavea-ng-leaflet-map is added to the root Leaflet map element
418+
*
419+
* This directive does not handle addition of any basemaps, etc. This must all be done in
420+
* child directives. See `./examples` directory of the source for a detailed example.
421+
*
422+
* @param {String=} width - Width of map in px or percentage
423+
* @param {String=} height - Height of map in px or percentage
424+
* @param {Object=} options - Default map options to instantiate map with.
425+
* If not provided, {@link az.leaflet.service:AZLeafletDefaults} is used.
426+
*/
306427
(function (angular) {
307428
'use strict';
308429

@@ -342,6 +463,17 @@
342463
AZLeafletData.setMap(map, attrs.id);
343464

344465
scope.$on('$destroy', onScopeDestroy);
466+
467+
/**
468+
* @ngdoc event
469+
* @name az.leaflet.directive:azLeaflet#az.leaflet.invalidatesize
470+
* @eventOf az.leaflet.directive:azLeaflet
471+
*
472+
* @description
473+
*
474+
* Trigger `'az.leaflet.invalidatesize'` in your application code to trigger a L.map.invalidateSize()
475+
* call on the next $digest cycle
476+
*/
345477
scope.$on('az.leaflet.invalidatesize', controller.invalidateMapSize);
346478

347479
function onScopeDestroy() {

docs/css/animations.css

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
.slide-reveal.ng-enter {
2+
-webkit-transition:0.5s linear all;
3+
-moz-transition:0.5s linear all;
4+
-o-transition:0.5s linear all;
5+
transition:0.5s linear all;
6+
7+
opacity:0.5;
8+
position:relative;
9+
opacity:0;
10+
top:10px;
11+
}
12+
.slide-reveal.ng-enter-active {
13+
top:0;
14+
opacity:1;
15+
}
16+
17+
.expand.ng-enter {
18+
-webkit-transition:0.3s cubic-bezier(0.250, 0.460, 0.450, 0.940) all;
19+
-moz-transition:0.3s cubic-bezier(0.250, 0.460, 0.450, 0.940) all;
20+
-o-transition:0.3s cubic-bezier(0.250, 0.460, 0.450, 0.940) all;
21+
transition:0.3s cubic-bezier(0.250, 0.460, 0.450, 0.940) all;
22+
23+
opacity:0;
24+
max-height:0;
25+
overflow:hidden;
26+
}
27+
.expand.ng-enter-active {
28+
opacity:1;
29+
max-height:40px;
30+
}
31+
32+
.expand.ng-leave {
33+
-webkit-transition:0.3s cubic-bezier(0.250, 0.460, 0.450, 0.940) all;
34+
-moz-transition:0.3s cubic-bezier(0.250, 0.460, 0.450, 0.940) all;
35+
-o-transition:0.3s cubic-bezier(0.250, 0.460, 0.450, 0.940) all;
36+
transition:0.3s cubic-bezier(0.250, 0.460, 0.450, 0.940) all;
37+
38+
opacity:1;
39+
max-height:40px;
40+
overflow:hidden;
41+
}
42+
.expand.ng-leave-active {
43+
opacity:0;
44+
max-height:0;
45+
}

0 commit comments

Comments
 (0)