Skip to content

Commit 95925ef

Browse files
committed
Added support for changing the legend values.
1 parent e04e9bb commit 95925ef

File tree

3 files changed

+29
-31
lines changed

3 files changed

+29
-31
lines changed

dist/angular-leaflet-directive.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -373,16 +373,18 @@
373373
var position = legend.position || 'bottomright';
374374
var leafletLegend;
375375
controller.getMap().then(function (map) {
376-
if (!isDefined(legend.url) && (!isArray(legend.colors) || !isArray(legend.labels) || legend.colors.length !== legend.labels.length)) {
377-
$log.warn('[AngularJS - Leaflet] legend.colors and legend.labels must be set.');
378-
} else if (isDefined(legend.url)) {
379-
$log.info('[AngularJS - Leaflet] loading arcgis legend service.');
380-
} else {
381-
// TODO: Watch array legend.
382-
leafletLegend = L.control({ position: position });
383-
leafletLegend.onAdd = leafletLegendHelpers.getOnAddArrayLegend(legend, legendClass);
384-
leafletLegend.addTo(map);
385-
}
376+
leafletScope.$watch('legend', function (legend) {
377+
if (!isDefined(legend.url) && (!isArray(legend.colors) || !isArray(legend.labels) || legend.colors.length !== legend.labels.length)) {
378+
$log.warn('[AngularJS - Leaflet] legend.colors and legend.labels must be set.');
379+
} else if (isDefined(legend.url)) {
380+
$log.info('[AngularJS - Leaflet] loading arcgis legend service.');
381+
} else {
382+
// TODO: Watch array legend.
383+
leafletLegend = L.control({ position: position });
384+
leafletLegend.onAdd = leafletLegendHelpers.getOnAddArrayLegend(legend, legendClass);
385+
leafletLegend.addTo(map);
386+
}
387+
});
386388
leafletScope.$watch('legend.url', function (newURL) {
387389
if (!isDefined(newURL)) {
388390
return;

0 commit comments

Comments
 (0)