{"action":"created","issue":{"url":"https://api.github.com/repos/angular-ui/angular-google-maps/issues/1382","labels_url":"https://api.github.com/repos/angular-ui/angular-google-maps/issues/1382/labels{/name}","comments_url":"https://api.github.com/repos/angular-ui/angular-google-maps/issues/1382/comments","events_url":"https://api.github.com/repos/angular-ui/angular-google-maps/issues/1382/events","html_url":"https://github.com/angular-ui/angular-google-maps/pull/1382","id":93647517,"number":1382,"title":"Resets _currentCheckNum in uiGmapIsReady.promise","user":{"login":"nantunes","id":209365,"avatar_url":"https://avatars.githubusercontent.com/u/209365?v=3","gravatar_id":"","url":"https://api.github.com/users/nantunes","html_url":"https://github.com/nantunes","followers_url":"https://api.github.com/users/nantunes/followers","following_url":"https://api.github.com/users/nantunes/following{/other_user}","gists_url":"https://api.github.com/users/nantunes/gists{/gist_id}","starred_url":"https://api.github.com/users/nantunes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nantunes/subscriptions","organizations_url":"https://api.github.com/users/nantunes/orgs","repos_url":"https://api.github.com/users/nantunes/repos","events_url":"https://api.github.com/users/nantunes/events{/privacy}","received_events_url":"https://api.github.com/users/nantunes/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-07-07T22:51:28Z","updated_at":"2015-07-22T10:30:08Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/angular-ui/angular-google-maps/pulls/1382","html_url":"https://github.com/angular-ui/angular-google-maps/pull/1382","diff_url":"https://github.com/angular-ui/angular-google-maps/pull/1382.diff","patch_url":"https://github.com/angular-ui/angular-google-maps/pull/1382.patch"},"body":"I was getting 'Your maps are not found we have checked the maximum amount of times. :)' after some destroy and recreating of map controls."},"comment":{"url":"https://api.github.com/repos/angular-ui/angular-google-maps/issues/comments/123655842","html_url":"https://github.com/angular-ui/angular-google-maps/pull/1382#issuecomment-123655842","issue_url":"https://api.github.com/repos/angular-ui/angular-google-maps/issues/1382","id":123655842,"user":{"login":"nantunes","id":209365,"avatar_url":"https://avatars.githubusercontent.com/u/209365?v=3","gravatar_id":"","url":"https://api.github.com/users/nantunes","html_url":"https://github.com/nantunes","followers_url":"https://api.github.com/users/nantunes/followers","following_url":"https://api.github.com/users/nantunes/following{/other_user}","gists_url":"https://api.github.com/users/nantunes/gists{/gist_id}","starred_url":"https://api.github.com/users/nantunes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nantunes/subscriptions","organizations_url":"https://api.github.com/users/nantunes/orgs","repos_url":"https://api.github.com/users/nantunes/repos","events_url":"https://api.github.com/users/nantunes/events{/privacy}","received_events_url":"https://api.github.com/users/nantunes/received_events","type":"User","site_admin":false},"created_at":"2015-07-22T10:30:08Z","updated_at":"2015-07-22T10:30:08Z","body":"Oh, I see... I'm calling promise only once in every map re-creation, but yes, there could be multiple listeners and that would reset the control variable globally each time.\r\n\r\nHow about that variable be promise specific? We could remove _currentCheckNum  altogether and then do like this:\r\n```coffeescript\r\npromise: (expectedInstances = 1, num_retries = 50) ->\r\n    d = $q.defer()\r\n    _checkIfReady(d, expectedInstances, num_retries)\r\n    d.promise\r\n```\r\n\r\nAnd at _checkIfReady:\r\n```coffeescript\r\n_checkIfReady = (deferred, expectedInstances, num_retries) ->\r\n    $timeout ->\r\n      if num_retries == 0\r\n        deferred.reject('Your maps are not found we have checked the maximum amount of times. :)')\r\n      if _ctr != expectedInstances\r\n        _checkIfReady(deferred, expectedInstances, --num_retries)\r\n      else\r\n        deferred.resolve(_promises())\r\n    , 100\r\n```\r\n\r\nWould it be ok for you, @nmccready? I can make a new PR if thats ok for you."}}