{"action":"created","comment":{"url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/pulls/comments/48108696","id":48108696,"diff_hunk":"@@ -117,24 +116,19 @@ - (void)layoutSubviews\n \n - (void)setAnnotations:(NSMutableArray *)annotations\n {\n-    _newAnnotations = annotations;\n-    [self performSelector:@selector(updateAnnotations) withObject:nil afterDelay:0.5];\n+    [self performSelector:@selector(updateAnnotations:) withObject:annotations afterDelay:0.5];\n }\n \n-- (void)updateAnnotations {\n-    if (_newAnnotations) {\n-        if (_annotations.count) {\n-            for (int i = 0; i < [_annotations count]; i++) {\n-                [_map removeAnnotations: _annotations];\n-            }\n-            _annotations = nil;\n-        }\n-\n-        _annotations = _newAnnotations;\n-        for (int i = 0; i < [_newAnnotations count]; i++) {\n-            [_map addAnnotation:_newAnnotations[i]];\n+- (void)updateAnnotations:(NSMutableArray *) annotations {\n+    for (int i = 0; i < [annotations count]; i++) {\n+        NSString *id = [annotations[i] id];\n+        if ([id length] != 0) {\n+            [_annotations setObject:[annotations objectAtIndex:i] forKey:id];\n+        } else {\n+            [_annotations setObject:[annotations objectAtIndex:i] forKey:[NSString stringWithFormat:@\"id-%d\", i]];","path":"ios/RCTMapboxGL/RCTMapboxGL.m","position":46,"original_position":46,"commit_id":"1f030aa31ecb3bec6646dd7fbbb49be6878febd0","original_commit_id":"1f030aa31ecb3bec6646dd7fbbb49be6878febd0","user":{"login":"1ec5","id":1231218,"avatar_url":"https://avatars.githubusercontent.com/u/1231218?v=3","gravatar_id":"","url":"https://api.github.com/users/1ec5","html_url":"https://github.com/1ec5","followers_url":"https://api.github.com/users/1ec5/followers","following_url":"https://api.github.com/users/1ec5/following{/other_user}","gists_url":"https://api.github.com/users/1ec5/gists{/gist_id}","starred_url":"https://api.github.com/users/1ec5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/1ec5/subscriptions","organizations_url":"https://api.github.com/users/1ec5/orgs","repos_url":"https://api.github.com/users/1ec5/repos","events_url":"https://api.github.com/users/1ec5/events{/privacy}","received_events_url":"https://api.github.com/users/1ec5/received_events","type":"User","site_admin":false},"body":"Keys can be anything: you might as well make the key an NSNumber in this case, like this: `@(i)`. That way no one can accidentally collide with it by giving an annotation an ID of `id-0` or whatever.\r\n\r\nAnother option would be to make the key required (`nonnull`).","created_at":"2015-12-20T21:44:22Z","updated_at":"2015-12-20T21:44:22Z","html_url":"https://github.com/mapbox/react-native-mapbox-gl/pull/198#discussion_r48108696","pull_request_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/pulls/198","_links":{"self":{"href":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/pulls/comments/48108696"},"html":{"href":"https://github.com/mapbox/react-native-mapbox-gl/pull/198#discussion_r48108696"},"pull_request":{"href":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/pulls/198"}}},"pull_request":{"url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/pulls/198","id":54186030,"html_url":"https://github.com/mapbox/react-native-mapbox-gl/pull/198","diff_url":"https://github.com/mapbox/react-native-mapbox-gl/pull/198.diff","patch_url":"https://github.com/mapbox/react-native-mapbox-gl/pull/198.patch","issue_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/issues/198","number":198,"state":"open","locked":false,"title":"Use ids for selecting annotations","user":{"login":"bsudekum","id":1058624,"avatar_url":"https://avatars.githubusercontent.com/u/1058624?v=3","gravatar_id":"","url":"https://api.github.com/users/bsudekum","html_url":"https://github.com/bsudekum","followers_url":"https://api.github.com/users/bsudekum/followers","following_url":"https://api.github.com/users/bsudekum/following{/other_user}","gists_url":"https://api.github.com/users/bsudekum/gists{/gist_id}","starred_url":"https://api.github.com/users/bsudekum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bsudekum/subscriptions","organizations_url":"https://api.github.com/users/bsudekum/orgs","repos_url":"https://api.github.com/users/bsudekum/repos","events_url":"https://api.github.com/users/bsudekum/events{/privacy}","received_events_url":"https://api.github.com/users/bsudekum/received_events","type":"User","site_admin":false},"body":"This changes:\r\n\r\n* Annotations will not be wiped away when new annotations are added to map\r\n* remove and selecting an annotation is done with an id vs a place in an array\r\n* adds `removeAllAnnotations` function\r\n\r\n/cc @christopherdro","created_at":"2015-12-19T20:33:18Z","updated_at":"2015-12-20T21:44:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7ef094862394aa36cac5a1db041bf43fe4637593","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/pulls/198/commits","review_comments_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/pulls/198/comments","review_comment_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/issues/198/comments","statuses_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/statuses/1f030aa31ecb3bec6646dd7fbbb49be6878febd0","head":{"label":"mapbox:anno-update","ref":"anno-update","sha":"1f030aa31ecb3bec6646dd7fbbb49be6878febd0","user":{"login":"mapbox","id":600935,"avatar_url":"https://avatars.githubusercontent.com/u/600935?v=3","gravatar_id":"","url":"https://api.github.com/users/mapbox","html_url":"https://github.com/mapbox","followers_url":"https://api.github.com/users/mapbox/followers","following_url":"https://api.github.com/users/mapbox/following{/other_user}","gists_url":"https://api.github.com/users/mapbox/gists{/gist_id}","starred_url":"https://api.github.com/users/mapbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapbox/subscriptions","organizations_url":"https://api.github.com/users/mapbox/orgs","repos_url":"https://api.github.com/users/mapbox/repos","events_url":"https://api.github.com/users/mapbox/events{/privacy}","received_events_url":"https://api.github.com/users/mapbox/received_events","type":"Organization","site_admin":false},"repo":{"id":34629135,"name":"react-native-mapbox-gl","full_name":"mapbox/react-native-mapbox-gl","owner":{"login":"mapbox","id":600935,"avatar_url":"https://avatars.githubusercontent.com/u/600935?v=3","gravatar_id":"","url":"https://api.github.com/users/mapbox","html_url":"https://github.com/mapbox","followers_url":"https://api.github.com/users/mapbox/followers","following_url":"https://api.github.com/users/mapbox/following{/other_user}","gists_url":"https://api.github.com/users/mapbox/gists{/gist_id}","starred_url":"https://api.github.com/users/mapbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapbox/subscriptions","organizations_url":"https://api.github.com/users/mapbox/orgs","repos_url":"https://api.github.com/users/mapbox/repos","events_url":"https://api.github.com/users/mapbox/events{/privacy}","received_events_url":"https://api.github.com/users/mapbox/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mapbox/react-native-mapbox-gl","description":"A Mapbox GL react native module for creating custom maps","fork":false,"url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl","forks_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/forks","keys_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/teams","hooks_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/hooks","issue_events_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/issues/events{/number}","events_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/events","assignees_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/assignees{/user}","branches_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/branches{/branch}","tags_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/tags","blobs_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/git/refs{/sha}","trees_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/statuses/{sha}","languages_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/languages","stargazers_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/stargazers","contributors_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/contributors","subscribers_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/subscribers","subscription_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/subscription","commits_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/commits{/sha}","git_commits_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/git/commits{/sha}","comments_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/comments{/number}","issue_comment_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/issues/comments{/number}","contents_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/contents/{+path}","compare_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/merges","archive_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/downloads","issues_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/issues{/number}","pulls_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/pulls{/number}","milestones_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/milestones{/number}","notifications_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/labels{/name}","releases_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/releases{/id}","created_at":"2015-04-26T20:08:07Z","updated_at":"2015-12-20T19:27:32Z","pushed_at":"2015-12-20T21:37:31Z","git_url":"git://github.com/mapbox/react-native-mapbox-gl.git","ssh_url":"git@github.com:mapbox/react-native-mapbox-gl.git","clone_url":"https://github.com/mapbox/react-native-mapbox-gl.git","svn_url":"https://github.com/mapbox/react-native-mapbox-gl","homepage":"","size":466,"stargazers_count":280,"watchers_count":280,"language":"Objective-C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":51,"mirror_url":null,"open_issues_count":26,"forks":51,"open_issues":26,"watchers":280,"default_branch":"master"}},"base":{"label":"mapbox:master","ref":"master","sha":"baeaa1fe4ca0b1eb2bd254de42ebff180a33a0e3","user":{"login":"mapbox","id":600935,"avatar_url":"https://avatars.githubusercontent.com/u/600935?v=3","gravatar_id":"","url":"https://api.github.com/users/mapbox","html_url":"https://github.com/mapbox","followers_url":"https://api.github.com/users/mapbox/followers","following_url":"https://api.github.com/users/mapbox/following{/other_user}","gists_url":"https://api.github.com/users/mapbox/gists{/gist_id}","starred_url":"https://api.github.com/users/mapbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapbox/subscriptions","organizations_url":"https://api.github.com/users/mapbox/orgs","repos_url":"https://api.github.com/users/mapbox/repos","events_url":"https://api.github.com/users/mapbox/events{/privacy}","received_events_url":"https://api.github.com/users/mapbox/received_events","type":"Organization","site_admin":false},"repo":{"id":34629135,"name":"react-native-mapbox-gl","full_name":"mapbox/react-native-mapbox-gl","owner":{"login":"mapbox","id":600935,"avatar_url":"https://avatars.githubusercontent.com/u/600935?v=3","gravatar_id":"","url":"https://api.github.com/users/mapbox","html_url":"https://github.com/mapbox","followers_url":"https://api.github.com/users/mapbox/followers","following_url":"https://api.github.com/users/mapbox/following{/other_user}","gists_url":"https://api.github.com/users/mapbox/gists{/gist_id}","starred_url":"https://api.github.com/users/mapbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapbox/subscriptions","organizations_url":"https://api.github.com/users/mapbox/orgs","repos_url":"https://api.github.com/users/mapbox/repos","events_url":"https://api.github.com/users/mapbox/events{/privacy}","received_events_url":"https://api.github.com/users/mapbox/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mapbox/react-native-mapbox-gl","description":"A Mapbox GL react native module for creating custom maps","fork":false,"url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl","forks_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/forks","keys_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/teams","hooks_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/hooks","issue_events_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/issues/events{/number}","events_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/events","assignees_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/assignees{/user}","branches_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/branches{/branch}","tags_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/tags","blobs_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/git/refs{/sha}","trees_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/statuses/{sha}","languages_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/languages","stargazers_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/stargazers","contributors_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/contributors","subscribers_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/subscribers","subscription_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/subscription","commits_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/commits{/sha}","git_commits_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/git/commits{/sha}","comments_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/comments{/number}","issue_comment_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/issues/comments{/number}","contents_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/contents/{+path}","compare_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/merges","archive_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/downloads","issues_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/issues{/number}","pulls_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/pulls{/number}","milestones_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/milestones{/number}","notifications_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/labels{/name}","releases_url":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/releases{/id}","created_at":"2015-04-26T20:08:07Z","updated_at":"2015-12-20T19:27:32Z","pushed_at":"2015-12-20T21:37:31Z","git_url":"git://github.com/mapbox/react-native-mapbox-gl.git","ssh_url":"git@github.com:mapbox/react-native-mapbox-gl.git","clone_url":"https://github.com/mapbox/react-native-mapbox-gl.git","svn_url":"https://github.com/mapbox/react-native-mapbox-gl","homepage":"","size":466,"stargazers_count":280,"watchers_count":280,"language":"Objective-C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":51,"mirror_url":null,"open_issues_count":26,"forks":51,"open_issues":26,"watchers":280,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/pulls/198"},"html":{"href":"https://github.com/mapbox/react-native-mapbox-gl/pull/198"},"issue":{"href":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/issues/198"},"comments":{"href":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/issues/198/comments"},"review_comments":{"href":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/pulls/198/comments"},"review_comment":{"href":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/pulls/198/commits"},"statuses":{"href":"https://api.github.com/repos/mapbox/react-native-mapbox-gl/statuses/1f030aa31ecb3bec6646dd7fbbb49be6878febd0"}}}}