{"action":"created","comment":{"url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/pulls/comments/43743297","id":43743297,"diff_hunk":"@@ -0,0 +1,96 @@\n+React                 = require 'react'\n+timeUtils             = require '../../util/time-utils'\n+cx                    = require 'classnames'\n+ComponentUsageExample = require '../documentation/component-usage-example'\n+Example               = require '../documentation/example-data'\n+Map                   = require './map.cjsx'\n+ToggleMapTracking     = require '../navigation/toggle-map-tracking'\n+MapTrackActions       = require '../../action/map-track-actions'\n+config                = require '../../config'\n+\n+class MapWithTracking extends React.Component\n+  @contextTypes:\n+    getStore: React.PropTypes.func.isRequired\n+    executeAction: React.PropTypes.func.isRequired\n+\n+  constructor: ->\n+    super\n+    #Check if we have a position already\n+    locationState = @context.getStore('PositionStore').getLocationState()\n+    if locationState.hasLocation\n+      initialZoom = 16\n+      initialLat = locationState.lat\n+      initialLon = locationState.lon\n+    else\n+      initialZoom = config.initialLocation.zoom\n+      initialLat = config.initialLocation.lat\n+      initialLon = config.initialLocation.lon\n+\n+    @state =\n+      zoom: initialZoom\n+      lat: initialLat\n+      lon: initialLon\n+\n+  componentWillMount: =>\n+    @context.getStore('MapTrackStore').addChangeListener @onTrackStatusChange\n+    @context.getStore('PositionStore').addChangeListener @onPositionChange\n+\n+  componentWillUnmount: =>\n+    @context.getStore('MapTrackStore').removeChangeListener @onTrackStatusChange\n+    @context.getStore('PositionStore').removeChangeListener @onPositionChange\n+\n+  disableMapTrack: =>\n+    @context.executeAction MapTrackActions.endMapTrack\n+\n+  onTrackStatusChange: =>\n+    locationState = @context.getStore('PositionStore').getLocationState()\n+    trackState = @context.getStore('MapTrackStore').getMapTrackState()\n+\n+    if locationState.hasLocation and trackState\n+      @setState\n+        zoom: undefined\n+        lat: locationState.lat\n+        lon: locationState.lon\n+    else\n+      @setState\n+        zoom: undefined\n+        lat: undefined\n+        lon: undefined\n+\n+  onPositionChange: (status) =>\n+    locationState = @context.getStore('PositionStore').getLocationState()\n+    trackState = @context.getStore('MapTrackStore').getMapTrackState()\n+\n+    if locationState.hasLocation and trackState\n+      newLat = locationState.lat\n+      newLon = locationState.lon\n+      @setState\n+        lat: newLat\n+        lon: newLon\n+\n+    if status.statusChanged\n+      @setState\n+        zoom: 16\n+        lat: locationState.lat\n+        lon: locationState.lon\n+        () => @context.executeAction MapTrackActions.startMapTrack #start map track because position was found\n+\n+  render: =>\n+    <Map className=\"fullscreen\" showStops={true} lat={@state.lat} lon={@state.lon} zoom={@state.zoom} disableMapTrack={@disableMapTrack}>","path":"app/component/map/map-with-tracking.cjsx","position":79,"original_position":79,"commit_id":"b1c0fe7abe9df868c7617ea768ece2d5680cc3fb","original_commit_id":"b1c0fe7abe9df868c7617ea768ece2d5680cc3fb","user":{"login":"hannesj","id":698100,"avatar_url":"https://avatars.githubusercontent.com/u/698100?v=3","gravatar_id":"","url":"https://api.github.com/users/hannesj","html_url":"https://github.com/hannesj","followers_url":"https://api.github.com/users/hannesj/followers","following_url":"https://api.github.com/users/hannesj/following{/other_user}","gists_url":"https://api.github.com/users/hannesj/gists{/gist_id}","starred_url":"https://api.github.com/users/hannesj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hannesj/subscriptions","organizations_url":"https://api.github.com/users/hannesj/orgs","repos_url":"https://api.github.com/users/hannesj/repos","events_url":"https://api.github.com/users/hannesj/events{/privacy}","received_events_url":"https://api.github.com/users/hannesj/received_events","type":"User","site_admin":false},"body":"Why should we have lat and lon in state versus retrieving them when redering?","created_at":"2015-11-03T12:48:44Z","updated_at":"2015-11-03T12:48:44Z","html_url":"https://github.com/HSLdevcom/digitransit-ui/pull/220#discussion_r43743297","pull_request_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/pulls/220","_links":{"self":{"href":"https://api.github.com/repos/HSLdevcom/digitransit-ui/pulls/comments/43743297"},"html":{"href":"https://github.com/HSLdevcom/digitransit-ui/pull/220#discussion_r43743297"},"pull_request":{"href":"https://api.github.com/repos/HSLdevcom/digitransit-ui/pulls/220"}}},"pull_request":{"url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/pulls/220","id":48774736,"html_url":"https://github.com/HSLdevcom/digitransit-ui/pull/220","diff_url":"https://github.com/HSLdevcom/digitransit-ui/pull/220.diff","patch_url":"https://github.com/HSLdevcom/digitransit-ui/pull/220.patch","issue_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/issues/220","number":220,"state":"open","locked":false,"title":"Dt 314 refactor positioning","user":{"login":"VilleMiekkoja","id":2777633,"avatar_url":"https://avatars.githubusercontent.com/u/2777633?v=3","gravatar_id":"","url":"https://api.github.com/users/VilleMiekkoja","html_url":"https://github.com/VilleMiekkoja","followers_url":"https://api.github.com/users/VilleMiekkoja/followers","following_url":"https://api.github.com/users/VilleMiekkoja/following{/other_user}","gists_url":"https://api.github.com/users/VilleMiekkoja/gists{/gist_id}","starred_url":"https://api.github.com/users/VilleMiekkoja/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VilleMiekkoja/subscriptions","organizations_url":"https://api.github.com/users/VilleMiekkoja/orgs","repos_url":"https://api.github.com/users/VilleMiekkoja/repos","events_url":"https://api.github.com/users/VilleMiekkoja/events{/privacy}","received_events_url":"https://api.github.com/users/VilleMiekkoja/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-26T17:58:59Z","updated_at":"2015-11-03T12:48:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"38984372cbc135e1801f6ed7838d9bc74bf222e9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/pulls/220/commits","review_comments_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/pulls/220/comments","review_comment_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/pulls/comments{/number}","comments_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/issues/220/comments","statuses_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/statuses/b1c0fe7abe9df868c7617ea768ece2d5680cc3fb","head":{"label":"HSLdevcom:DT-314-refactor-positioning","ref":"DT-314-refactor-positioning","sha":"b1c0fe7abe9df868c7617ea768ece2d5680cc3fb","user":{"login":"HSLdevcom","id":2813507,"avatar_url":"https://avatars.githubusercontent.com/u/2813507?v=3","gravatar_id":"","url":"https://api.github.com/users/HSLdevcom","html_url":"https://github.com/HSLdevcom","followers_url":"https://api.github.com/users/HSLdevcom/followers","following_url":"https://api.github.com/users/HSLdevcom/following{/other_user}","gists_url":"https://api.github.com/users/HSLdevcom/gists{/gist_id}","starred_url":"https://api.github.com/users/HSLdevcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HSLdevcom/subscriptions","organizations_url":"https://api.github.com/users/HSLdevcom/orgs","repos_url":"https://api.github.com/users/HSLdevcom/repos","events_url":"https://api.github.com/users/HSLdevcom/events{/privacy}","received_events_url":"https://api.github.com/users/HSLdevcom/received_events","type":"Organization","site_admin":false},"repo":{"id":32916096,"name":"digitransit-ui","full_name":"HSLdevcom/digitransit-ui","owner":{"login":"HSLdevcom","id":2813507,"avatar_url":"https://avatars.githubusercontent.com/u/2813507?v=3","gravatar_id":"","url":"https://api.github.com/users/HSLdevcom","html_url":"https://github.com/HSLdevcom","followers_url":"https://api.github.com/users/HSLdevcom/followers","following_url":"https://api.github.com/users/HSLdevcom/following{/other_user}","gists_url":"https://api.github.com/users/HSLdevcom/gists{/gist_id}","starred_url":"https://api.github.com/users/HSLdevcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HSLdevcom/subscriptions","organizations_url":"https://api.github.com/users/HSLdevcom/orgs","repos_url":"https://api.github.com/users/HSLdevcom/repos","events_url":"https://api.github.com/users/HSLdevcom/events{/privacy}","received_events_url":"https://api.github.com/users/HSLdevcom/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/HSLdevcom/digitransit-ui","description":"Digitransit UI","fork":false,"url":"https://api.github.com/repos/HSLdevcom/digitransit-ui","forks_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/forks","keys_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/teams","hooks_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/hooks","issue_events_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/issues/events{/number}","events_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/events","assignees_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/assignees{/user}","branches_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/branches{/branch}","tags_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/tags","blobs_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/statuses/{sha}","languages_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/languages","stargazers_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/stargazers","contributors_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/contributors","subscribers_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/subscribers","subscription_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/subscription","commits_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/contents/{+path}","compare_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/merges","archive_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/downloads","issues_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/issues{/number}","pulls_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/pulls{/number}","milestones_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/milestones{/number}","notifications_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/labels{/name}","releases_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/releases{/id}","created_at":"2015-03-26T08:38:16Z","updated_at":"2015-10-31T12:51:57Z","pushed_at":"2015-11-03T12:46:31Z","git_url":"git://github.com/HSLdevcom/digitransit-ui.git","ssh_url":"git@github.com:HSLdevcom/digitransit-ui.git","clone_url":"https://github.com/HSLdevcom/digitransit-ui.git","svn_url":"https://github.com/HSLdevcom/digitransit-ui","homepage":"http://digitransit.fi/openjourneyplanner-ui/","size":6524,"stargazers_count":22,"watchers_count":22,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":6,"forks":5,"open_issues":6,"watchers":22,"default_branch":"master"}},"base":{"label":"HSLdevcom:master","ref":"master","sha":"660cc8c47f53b3b12e5cdf810d2417b48b8891e4","user":{"login":"HSLdevcom","id":2813507,"avatar_url":"https://avatars.githubusercontent.com/u/2813507?v=3","gravatar_id":"","url":"https://api.github.com/users/HSLdevcom","html_url":"https://github.com/HSLdevcom","followers_url":"https://api.github.com/users/HSLdevcom/followers","following_url":"https://api.github.com/users/HSLdevcom/following{/other_user}","gists_url":"https://api.github.com/users/HSLdevcom/gists{/gist_id}","starred_url":"https://api.github.com/users/HSLdevcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HSLdevcom/subscriptions","organizations_url":"https://api.github.com/users/HSLdevcom/orgs","repos_url":"https://api.github.com/users/HSLdevcom/repos","events_url":"https://api.github.com/users/HSLdevcom/events{/privacy}","received_events_url":"https://api.github.com/users/HSLdevcom/received_events","type":"Organization","site_admin":false},"repo":{"id":32916096,"name":"digitransit-ui","full_name":"HSLdevcom/digitransit-ui","owner":{"login":"HSLdevcom","id":2813507,"avatar_url":"https://avatars.githubusercontent.com/u/2813507?v=3","gravatar_id":"","url":"https://api.github.com/users/HSLdevcom","html_url":"https://github.com/HSLdevcom","followers_url":"https://api.github.com/users/HSLdevcom/followers","following_url":"https://api.github.com/users/HSLdevcom/following{/other_user}","gists_url":"https://api.github.com/users/HSLdevcom/gists{/gist_id}","starred_url":"https://api.github.com/users/HSLdevcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HSLdevcom/subscriptions","organizations_url":"https://api.github.com/users/HSLdevcom/orgs","repos_url":"https://api.github.com/users/HSLdevcom/repos","events_url":"https://api.github.com/users/HSLdevcom/events{/privacy}","received_events_url":"https://api.github.com/users/HSLdevcom/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/HSLdevcom/digitransit-ui","description":"Digitransit UI","fork":false,"url":"https://api.github.com/repos/HSLdevcom/digitransit-ui","forks_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/forks","keys_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/teams","hooks_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/hooks","issue_events_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/issues/events{/number}","events_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/events","assignees_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/assignees{/user}","branches_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/branches{/branch}","tags_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/tags","blobs_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/statuses/{sha}","languages_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/languages","stargazers_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/stargazers","contributors_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/contributors","subscribers_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/subscribers","subscription_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/subscription","commits_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/contents/{+path}","compare_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/merges","archive_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/downloads","issues_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/issues{/number}","pulls_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/pulls{/number}","milestones_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/milestones{/number}","notifications_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/labels{/name}","releases_url":"https://api.github.com/repos/HSLdevcom/digitransit-ui/releases{/id}","created_at":"2015-03-26T08:38:16Z","updated_at":"2015-10-31T12:51:57Z","pushed_at":"2015-11-03T12:46:31Z","git_url":"git://github.com/HSLdevcom/digitransit-ui.git","ssh_url":"git@github.com:HSLdevcom/digitransit-ui.git","clone_url":"https://github.com/HSLdevcom/digitransit-ui.git","svn_url":"https://github.com/HSLdevcom/digitransit-ui","homepage":"http://digitransit.fi/openjourneyplanner-ui/","size":6524,"stargazers_count":22,"watchers_count":22,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":6,"forks":5,"open_issues":6,"watchers":22,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/HSLdevcom/digitransit-ui/pulls/220"},"html":{"href":"https://github.com/HSLdevcom/digitransit-ui/pull/220"},"issue":{"href":"https://api.github.com/repos/HSLdevcom/digitransit-ui/issues/220"},"comments":{"href":"https://api.github.com/repos/HSLdevcom/digitransit-ui/issues/220/comments"},"review_comments":{"href":"https://api.github.com/repos/HSLdevcom/digitransit-ui/pulls/220/comments"},"review_comment":{"href":"https://api.github.com/repos/HSLdevcom/digitransit-ui/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/HSLdevcom/digitransit-ui/pulls/220/commits"},"statuses":{"href":"https://api.github.com/repos/HSLdevcom/digitransit-ui/statuses/b1c0fe7abe9df868c7617ea768ece2d5680cc3fb"}}}}