Skip to content
This repository has been archived by the owner on Dec 1, 2020. It is now read-only.

Commit

Permalink
Fixed gulp error again
Browse files Browse the repository at this point in the history
  • Loading branch information
eas604 committed Mar 30, 2015
1 parent 4b85363 commit 8f0420e
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
59 changes: 59 additions & 0 deletions dist/angular-esri-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,3 +411,62 @@
});

})(angular);

(function(angular) {
'use strict';

/**
* @ngdoc directive
* @name esriApp.directive:esriLegend
* @description
* # esriLegend
*/
angular.module('esri.map')
.directive('esriLegend', function ($document, $q) {
return {
//run last
priority: -10,
scope:{},
replace: true,
// require the esriMap controller
// you can access these controllers in the link function
require: ['^esriMap'],

// now we can link our directive to the scope, but we can also add it to the map..
link: function(scope, element, attrs, controllers){
// controllers is now an array of the controllers from the 'require' option
var mapController = controllers[0];
var targetId = attrs.targetId || attrs.id;
var legendDeferred = $q.defer();

require(['esri/dijit/Legend', 'dijit/registry'], function (Legend, registry) {
mapController.getMap().then(function(map) {
var opts = {
map: map
};
var layerInfos = mapController.getLayerInfos();
if (layerInfos) {
opts.layerInfos = layerInfos;
}
// NOTE: need to come up w/ a way to that is not based on id
// or handle destroy at end of this view's lifecyle
var legend = registry.byId(targetId);
if (legend) {
legend.destroyRecursive();
}
legend = new Legend(opts, targetId);
legend.startup();
scope.layers = legend.layers;
angular.forEach(scope.layers, function(layer, i) {
scope.$watch('layers['+i+'].renderer',function() {
legend.refresh();
});
});
legendDeferred.resolve(legend);
});
});
}
};
});

})(angular);
2 changes: 1 addition & 1 deletion dist/angular-esri-map.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8f0420e

Please sign in to comment.