Skip to content

Commit 41ae67b

Browse files
committed
Merge pull request tombatossals#943 from elesdoar/master
Fix Toggling 'group' overlay visibility gives error
2 parents 0ed06f2 + d99f1a8 commit 41ae67b

File tree

6 files changed

+64
-44
lines changed

6 files changed

+64
-44
lines changed

dist/angular-leaflet-directive.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* angular-leaflet-directive 0.8.8 2015-09-09
2+
* angular-leaflet-directive 0.8.8 2015-09-16
33
* angular-leaflet-directive - An AngularJS directive to easily interact with Leaflet maps
44
* git: https://github.com/tombatossals/angular-leaflet-directive
55
*/
@@ -1589,10 +1589,12 @@ angular.module("leaflet-directive")
15891589
});
15901590
params.options.loadedDefer = function() {
15911591
var defers = [];
1592-
for (var i = 0; i < params.options.layers.length; i++) {
1593-
var d = params.options.layers[i].layerOptions.loadedDefer;
1594-
if(isDefined(d)) {
1595-
defers.push(d);
1592+
if(isDefined(params.options.layers)) {
1593+
for (var i = 0; i < params.options.layers.length; i++) {
1594+
var d = params.options.layers[i].layerOptions.loadedDefer;
1595+
if(isDefined(d)) {
1596+
defers.push(d);
1597+
}
15961598
}
15971599
}
15981600
return defers;
@@ -1943,15 +1945,19 @@ angular.module("leaflet-directive")
19431945
var defers = layerOptions.loadedDefer();
19441946
$log.debug('Loaded Deferred', defers);
19451947
var count = defers.length;
1946-
var resolve = function() {
1947-
count--;
1948-
if(count === 0) {
1949-
map.removeLayer(layer);
1950-
}
1951-
};
1948+
if(count > 0) {
1949+
var resolve = function() {
1950+
count--;
1951+
if(count === 0) {
1952+
map.removeLayer(layer);
1953+
}
1954+
};
19521955

1953-
for(var i = 0; i < defers.length; i++) {
1954-
defers[i].promise.then(resolve);
1956+
for(var i = 0; i < defers.length; i++) {
1957+
defers[i].promise.then(resolve);
1958+
}
1959+
} else {
1960+
map.removeLayer(layer);
19551961
}
19561962
} else {
19571963
layerOptions.loadedDefer.promise.then(function() {
@@ -5110,6 +5116,7 @@ angular.module("leaflet-directive")
51105116
'drag',
51115117
'dragend',
51125118
'zoomstart',
5119+
'zoomanim',
51135120
'zoomend',
51145121
'zoomlevelschange',
51155122
'resize',

dist/angular-leaflet-directive.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-leaflet-directive_dev_mapped.js

Lines changed: 20 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-leaflet-directive_dev_mapped.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/0506-markers-groups-example.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta name="viewport" content="width=device-width, initial-scale=1.0">
55
<script src="../bower_components/angular/angular.min.js"></script>
66
<script src="../bower_components/leaflet/dist/leaflet.js"></script><script src="../bower_components/angular-simple-logger/dist/index.js"></script>
7-
<script src="../dist/angular-leaflet-directive.min.js"></script>
7+
<script src="../dist/angular-leaflet-directive.js"></script>
88
<script src="../bower_components/jquery/dist/jquery.min.js"></script>
99
<link rel="stylesheet" href="../bower_components/leaflet/dist/leaflet.css" />
1010
<script>

src/services/leafletLayerHelpers.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,12 @@ angular.module("leaflet-directive")
147147
});
148148
params.options.loadedDefer = function() {
149149
var defers = [];
150-
for (var i = 0; i < params.options.layers.length; i++) {
151-
var d = params.options.layers[i].layerOptions.loadedDefer;
152-
if(isDefined(d)) {
153-
defers.push(d);
150+
if(isDefined(params.options.layers)) {
151+
for (var i = 0; i < params.options.layers.length; i++) {
152+
var d = params.options.layers[i].layerOptions.loadedDefer;
153+
if(isDefined(d)) {
154+
defers.push(d);
155+
}
154156
}
155157
}
156158
return defers;
@@ -501,15 +503,19 @@ angular.module("leaflet-directive")
501503
var defers = layerOptions.loadedDefer();
502504
$log.debug('Loaded Deferred', defers);
503505
var count = defers.length;
504-
var resolve = function() {
505-
count--;
506-
if(count === 0) {
507-
map.removeLayer(layer);
508-
}
509-
};
506+
if(count > 0) {
507+
var resolve = function() {
508+
count--;
509+
if(count === 0) {
510+
map.removeLayer(layer);
511+
}
512+
};
510513

511-
for(var i = 0; i < defers.length; i++) {
512-
defers[i].promise.then(resolve);
514+
for(var i = 0; i < defers.length; i++) {
515+
defers[i].promise.then(resolve);
516+
}
517+
} else {
518+
map.removeLayer(layer);
513519
}
514520
} else {
515521
layerOptions.loadedDefer.promise.then(function() {

0 commit comments

Comments
 (0)