{"action":"reopened","issue":{"url":"https://api.github.com/repos/tombatossals/angular-leaflet-directive/issues/962","labels_url":"https://api.github.com/repos/tombatossals/angular-leaflet-directive/issues/962/labels{/name}","comments_url":"https://api.github.com/repos/tombatossals/angular-leaflet-directive/issues/962/comments","events_url":"https://api.github.com/repos/tombatossals/angular-leaflet-directive/issues/962/events","html_url":"https://github.com/tombatossals/angular-leaflet-directive/issues/962","id":108510426,"number":962,"title":"Removing control throws error - TypeError: map.hasControl is not a function","user":{"login":"skray","id":3921751,"avatar_url":"https://avatars.githubusercontent.com/u/3921751?v=3","gravatar_id":"","url":"https://api.github.com/users/skray","html_url":"https://github.com/skray","followers_url":"https://api.github.com/users/skray/followers","following_url":"https://api.github.com/users/skray/following{/other_user}","gists_url":"https://api.github.com/users/skray/gists{/gist_id}","starred_url":"https://api.github.com/users/skray/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skray/subscriptions","organizations_url":"https://api.github.com/users/skray/orgs","repos_url":"https://api.github.com/users/skray/repos","events_url":"https://api.github.com/users/skray/events{/privacy}","received_events_url":"https://api.github.com/users/skray/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-27T03:19:00Z","updated_at":"2015-11-02T15:13:15Z","closed_at":null,"body":"I ran into this trying to use the Leaflet.draw plugin and was able to recreate it in [this fiddle](http://jsfiddle.net/xkwgkyuL/) (click the 'Remove Controls' button to trigger the error).\r\n\r\nIf you have controls in your map and use the `controls` directive, like this:\r\n\r\n```javascript\r\n$scope.controls = { draw: {} };\r\n``` \r\n\r\nand then remove the control from the controls object later, like this:\r\n\r\n```javascript\r\n$scope.controls = { };\r\n```\r\n\r\nThis error is thrown:\r\n\r\n![angular-leaflet-directive-error](https://cloud.githubusercontent.com/assets/3921751/10120964/bab5a15c-649b-11e5-8e63-915902129082.png)\r\n\r\nIt seems the culprit is [this line](https://github.com/tombatossals/angular-leaflet-directive/blob/master/src/directives/controls.js#L29), where it tries to call `map.hasControl()`, but I cannot find the `hasControl` method defined in either the leaflet.js source or in this project.\r\n\r\nIf this is just me misunderstanding how to work with controls, I'd love to know what I'm doing wrong. If this is a bug, I'd be happy to try to put a pull request in to fix it."}}