tombatossals / angular-leaflet-directive

AngularJS directive to embed an interact with maps managed by Leaflet library
http://tombatossals.github.io/angular-leaflet-directive
MIT License
1.5k stars 635 forks source link

error when adding custom controls because of "for in" usage to iterate over array #1024

Open ud09 opened 8 years ago

ud09 commented 8 years ago

Hi, similar to https://github.com/tombatossals/angular-leaflet-directive/issues/899 and https://github.com/tombatossals/angular-leaflet-directive/pull/884 extending Array.prototype, breaks the code when adding custom controls array.

if (isArray(customControlValue)) {
    for (var i in customControlValue) {

It's better not to use "for in" to iterate over arrays.

Same error also occurs in angular-simple-logger.js

_fns = ['debug', 'info', 'warn', 'error', 'log'];

and iterating over _fns

for (key in _fns) 
ud09 commented 8 years ago

Another code that causes error in _createLayersControl method: passing empty arrays instead of passing objects. []'s for baselayers and overlays should be replaced with {}s

var control;
if (defaults.controls.layers && isDefined(defaults.controls.layers.control)) {
    control = defaults.controls.layers.control.apply(this, [[], [], controlOptions]); 
} else {
    control = new L.control.layers([], [], controlOptions);
}