title: how to calculate distance between two latitude and longitude using angulajs?
body: <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$http.get('*****').success(function(data,dealers,response)
  {    
   $scope.items = data;
   $scope.item ='';
   console.log(data);
  var shoplatit=data.S_Location.Latitude;
   var shoplong=data.S_Location.Longitude;
                 
  });
  
  $scope.nearme = function($scope) {
   if (navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(function (position) {
                  mysrclat = position.coords.latitude; 
                  mysrclong = position.coords.longitude;
                  console.log(mysrclat);
                  console.log(mysrclong);
          });
          
      }
    i tried like this but its not working getting  deg2rad is not defined erro
  var lat1 =15.008809;
  var lat2 =78.659096;
  
  var lon1 =13.90457539;
  var lon2 =78.5855514
  
    var R = 6371; // Radius of the earth in km
    var dLat = deg2rad(lat2-lat1);  // deg2rad below
    var dLon = deg2rad(lon2-lon1); 
    var a = 
      Math.sin(dLat/2) * Math.sin(dLat/2) +
      Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * 
      Math.sin(dLon/2) * Math.sin(dLon/2)
      ; 
    var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
    var d = R * c; // Distance in km
     console.log(d);</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div ng-controller="ListingCtrl" &gt;
    &lt;div data-ng-init="nearme()"&gt;
      
      &lt;div class="list card" data-ng-repeat="item in items"&gt;
      &lt;h2&gt;{{item.Store_Name}} &lt;/h2&gt;{{item.S_Location.Latitude}}&lt;br&gt;{{item.S_Location.Longitude}}
      &lt;p&gt;{{item.S_Address}}&lt;/p&gt; 
     &lt;h1&gt;here i want show distance in km&lt;/h1&gt;
    &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I have stored store latitude and longitude in mongodb. In listing page i am getting customer latitude and langitude using navigator.geolocation.i want to calculate distance between two latitiude and longitude .i have enclosed my code</p>