title: How to build a Runkeeper-style GPS log on map?
body: <p>I'm trying to build a mobile application using Ionic Framework and Angular.js.
  Part of this app will be a view where you start logging your GPS position on a map. When you finish logging it you should see the route you took and be informed of the distance and time it took. Pretty much Runkeeper / Endomondo style, but simpler.</p>
  
  <p>Is this even possible in Ionic / Angular? Or is Native iOS / Android needed?
  If it is possible somehow, can you help me get started?
  My searches here on Stackoverflow seem to indicate it is possible somehow but all questions are too advanced, the author's are already in the middle of it. I need help finding the starting point.</p>
  
  <p>I've asked this question in Ionic's forum (<a href="http://forum.ionicframework.com/t/can-i-build-gps-logging-on-map-in-ionic/9296/2" rel="nofollow">http://forum.ionicframework.com/t/can-i-build-gps-logging-on-map-in-ionic/9296/2</a>) but it's been over 12 hours now without a reply so I'm placing my hopes on you guys here at Stackoverflow.
  I'm new to programming so please be patient and don't assume I know too much. Thanks!</p>
  
  <p>I don't have any map preferences. I would go with Google Maps unless someone says differently.
  I'm working on a Mac. I have Ionic, cordova, angular.js and node.js installed.</p>
  
  <p><strong>Update Sep 9, 09:43 CET:</strong>
  I've gotten a tip to look into ng-cordova's plugin "$cordovaGeolocation". I'm doing that now and I'll report here later.</p>
  
  <p><strong>Update Sep 9, 10:50 CET</strong>
  Ok I've installed ngCordova and the $cordovaGeolocation plugin.
  I'm getting the location correct, it seems.
  But now how do I start saving these locations over time? A button should start this and end it. 
  (and then show each datapoint on a map, or ideally draw a line between them from start to finish)</p>
  
  <p><strong>Update Sep 10, 11:15 CET</strong>
  I now have this code in a controller. It's from the ngCordova $cordovaGeolocation plugin.
  It seems to only run once. How do I keep feeding an array with the position over time?</p>
  
  <pre><code>        $cordovaGeolocation
          .getCurrentPosition()
          .then(function (position) {
              var lat  = position.coords.latitude
              var long = position.coords.longitude
          }, function(err) {
              // error
              alert('code: '    + err.code    + '\n' +
                  'message: ' + err.message + '\n');
          });
  
      // begin watching
      var watch = $cordovaGeolocation.watchPosition({ frequency: 1000 });
      watch.promise.then(function() { /* Not  used */ },
          function(err) {
              // An error occurred.
              alert('code: '    + err.code    + '\n' +
                  'message: ' + err.message + '\n');
          },
          function(position) {
              // Active updates of the position here
              // position.coords.[ latitude / longitude]
              var element = document.getElementById('geolocation');
              element.innerHTML = 'Latitude: '  + position.coords.latitude      + '&lt;br /&gt;' +
                  'Longitude: ' + position.coords.longitude     + '&lt;br /&gt;' +
                  'Timestamp: ' + position.timestamp + '&lt;br /&gt;' +
              '&lt;hr /&gt;'      + element.innerHTML;
          });
      // clear watch
      $cordovaGeolocation.clearWatch(watch.watchID)
  </code></pre>