I'm trying to show the nearest branch location in a map.SO i want to get the branch which has the least difference between the current location and the branch location. i have taken the differenec like this.
for(var i=0;i<$scope.locations.BranchAndAtms.length;i++){
var mapObject = $scope.locations.BranchAndAtms[i];
var differenceLat = (mapObject.lat - c.latitude);
var differenceLon = (mapObject.lon - c.longitude);
var Difference = (differenceLat + differenceLon);
alert(Difference );
Now i get the difference between every branch in my array.how to take the value with the least difference.
NOTE: difference i get comes in minus as well as positive values.