|
8 | 8 |
|
9 | 9 | })(angular);
|
10 | 10 |
|
| 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 | + */ |
11 | 26 | (function () {
|
12 | 27 | 'use strict';
|
13 | 28 |
|
|
55 | 70 |
|
56 | 71 | })();
|
57 | 72 |
|
| 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 | + */ |
58 | 86 | (function () {
|
59 | 87 | 'use strict';
|
60 | 88 |
|
|
90 | 118 | .factory('AZLeafletComponentFactory', LeafletComponent);
|
91 | 119 | })();
|
92 | 120 |
|
| 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 | + */ |
93 | 130 | (function () {
|
94 | 131 | 'use strict';
|
95 | 132 |
|
|
110 | 147 | }
|
111 | 148 |
|
112 | 149 | /**
|
| 150 | + * @ngdoc function |
| 151 | + * @name az.leaflet.controller:AZLeafletController#getMap |
| 152 | + * @methodOf az.leaflet.controller:AZLeafletController |
| 153 | + * |
| 154 | + * @description |
113 | 155 | * Get a promise reference to the map object created by the directive
|
| 156 | + * |
114 | 157 | * @return {Promise} Resolves with an L.map object
|
115 | 158 | */
|
116 | 159 | function getMap() {
|
|
141 | 184 | angular.module('az.leaflet')
|
142 | 185 | .controller('AZLeafletController', LeafletController);
|
143 | 186 | })();
|
| 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 | + */ |
144 | 195 | (function () {
|
145 | 196 | 'use strict';
|
146 | 197 |
|
147 |
| - /** |
148 |
| - * LeafletData stores references to L.map objects instantiated by the az-leaflet directive. |
149 |
| - */ |
150 | 198 | /*@ngInject*/
|
151 | 199 | LeafletData.$inject = ["$log", "$q"];
|
152 | 200 | function LeafletData($log, $q) {
|
153 | 201 | var maps = {};
|
154 | 202 |
|
155 | 203 | var module = {
|
| 204 | + |
156 | 205 | getMap: getMap,
|
157 | 206 | setMap: setMap,
|
158 | 207 | deleteMap: deleteMap
|
|
223 | 272 | }
|
224 | 273 |
|
225 | 274 | /**
|
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() |
229 | 285 | */
|
230 | 286 | function setMap(map, scopeId) {
|
231 | 287 | var defer = getUnresolvedDefer(maps, scopeId);
|
|
234 | 290 | }
|
235 | 291 |
|
236 | 292 | /**
|
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 |
239 | 296 | *
|
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 |
242 | 304 | */
|
243 | 305 | function getMap(scopeId) {
|
244 | 306 | var defer = getDefer(maps, scopeId);
|
245 | 307 | return defer.promise;
|
246 | 308 | }
|
247 | 309 |
|
| 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 | + */ |
248 | 323 | function deleteMap(scopeId) {
|
249 | 324 | var id = obtainEffectiveMapId(maps, scopeId);
|
250 | 325 | $log.info(maps, id);
|
|
255 | 330 | angular.module('az.leaflet')
|
256 | 331 | .service('AZLeafletData', LeafletData);
|
257 | 332 | })();
|
| 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 | + */ |
258 | 343 | (function() {
|
259 | 344 | 'use strict';
|
260 | 345 |
|
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 |
| - */ |
266 | 346 | /*@ngInject*/
|
267 | 347 | function LeafletDefaultsProvider() {
|
268 | 348 | var svc = this;
|
|
273 | 353 | };
|
274 | 354 |
|
275 | 355 | /**
|
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 |
278 | 374 | */
|
279 | 375 | svc.setDefaults = function (newDefaults) {
|
280 | 376 | angular.merge(defaults, newDefaults);
|
281 | 377 | };
|
282 | 378 |
|
283 | 379 | svc.$get = LeafletDefaults;
|
284 | 380 |
|
285 |
| - /** Read-only wrapper around defaults */ |
| 381 | + /** |
| 382 | + * @ngdoc service |
| 383 | + * @name az.leaflet.service:AZLeafletDefaults |
| 384 | + */ |
286 | 385 | /*@ngInject*/
|
287 | 386 | function LeafletDefaults() {
|
288 | 387 | var module = {
|
|
291 | 390 | return module;
|
292 | 391 |
|
293 | 392 | /**
|
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 |
296 | 398 | */
|
297 | 399 | function get() {
|
298 | 400 | return angular.extend({}, defaults);
|
|
303 | 405 | angular.module('az.leaflet')
|
304 | 406 | .provider('AZLeafletDefaults', LeafletDefaultsProvider);
|
305 | 407 | })();
|
| 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 | + */ |
306 | 427 | (function (angular) {
|
307 | 428 | 'use strict';
|
308 | 429 |
|
|
342 | 463 | AZLeafletData.setMap(map, attrs.id);
|
343 | 464 |
|
344 | 465 | 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 | + */ |
345 | 477 | scope.$on('az.leaflet.invalidatesize', controller.invalidateMapSize);
|
346 | 478 |
|
347 | 479 | function onScopeDestroy() {
|
|
0 commit comments