{"action":"reopened","issue":{"url":"https://api.github.com/repos/tombatossals/angular-leaflet-directive/issues/668","labels_url":"https://api.github.com/repos/tombatossals/angular-leaflet-directive/issues/668/labels{/name}","comments_url":"https://api.github.com/repos/tombatossals/angular-leaflet-directive/issues/668/comments","events_url":"https://api.github.com/repos/tombatossals/angular-leaflet-directive/issues/668/events","html_url":"https://github.com/tombatossals/angular-leaflet-directive/issues/668","id":65433836,"number":668,"title":"leafletDataHelper.getLayers returning old data","user":{"login":"rikbosch","id":549975,"avatar_url":"https://avatars.githubusercontent.com/u/549975?v=3","gravatar_id":"","url":"https://api.github.com/users/rikbosch","html_url":"https://github.com/rikbosch","followers_url":"https://api.github.com/users/rikbosch/followers","following_url":"https://api.github.com/users/rikbosch/following{/other_user}","gists_url":"https://api.github.com/users/rikbosch/gists{/gist_id}","starred_url":"https://api.github.com/users/rikbosch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rikbosch/subscriptions","organizations_url":"https://api.github.com/users/rikbosch/orgs","repos_url":"https://api.github.com/users/rikbosch/repos","events_url":"https://api.github.com/users/rikbosch/events{/privacy}","received_events_url":"https://api.github.com/users/rikbosch/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-31T11:52:39Z","updated_at":"2015-11-02T17:09:47Z","closed_at":null,"body":"I'm trying to adjust the map's bounds to the bounds of a featureGroup.\r\n\r\nHowever, when retrieving the bounds of the group, it contains no marker layers.\r\n\r\nI'm calling the following function after setting the markers in the $scope object:\r\n\r\n```javascript\r\n $scope.layers = {\r\n    baselayers: {},\r\n    overlays: {\r\n        primary: {\r\n            type: 'featureGroup',\r\n            name: 'Primary Lines',\r\n            visible: true\r\n        },\r\n\r\n        secundary: {\r\n            type: 'featureGroup',\r\n            name: 'secundary',\r\n            visible: false\r\n        }\r\n    }\r\n};\r\n\r\n$scope.markers = {};\r\n\r\nmyApiService.getMarkerData()\r\n    .then(function(data) {\r\n        $scope.markers = mapMarkers(data.lines);\r\n        fitToLayer('primary');\r\n    });\r\n\r\nfunction fitToLayer(name) {\r\n    leafletData.getMap()\r\n        .then(function(map) {\r\n            leafletData.getLayers()\r\n                .then(function(layers) {\r\n                    var layer = layers.overlays[name]; //<== layer has no markers defined \r\n                    map.fitBounds(layer.getBounds()); //<==throws error 'lat' undefined\r\n                });\r\n        });\r\n}\r\n\r\nfunction mapMarkers(lines) {\r\n    return lines.map(function(line) {\r\n        return {\r\n            layer: 'primary',\r\n            lat: line.x,\r\n            lng: line.y,\r\n            key: line.id\r\n        };\r\n    });\r\n}\r\n```\r\n\r\nthe full error:\r\n```javascript\r\nTypeError: Cannot read property 'lat' of undefined\r\n    at Object.L.LatLngBounds.getNorth (leaflet-src.js:1336)\r\n    at Object.L.LatLngBounds.getNorthWest (leaflet-src.js:1316)\r\n    at L.Map.L.Class.extend.getBoundsZoom (leaflet-src.js:1887)\r\n    at L.Map.L.Class.extend.fitBounds (leaflet-src.js:1635)\r\n    at main.controller.js:95\r\n    at processQueue (angular.js:13248)\r\n    at angular.js:13264\r\n    at Scope.$get.Scope.$eval (angular.js:14466)\r\n    at Scope.$get.Scope.$digest (angular.js:14282)\r\n    at Scope.$get.Scope.$apply (angular.js:14571)\r\n```\r\n"}}