Currently utilizing AngularJs and Ionic for the development of a Hybrid Mobile App. The data is being retrieved from an API.
[{"Location":"Brierfield"},
{"Location":"Centreville"},
{"Location":"Chelsea"},
{"Location":"Coosa Pines"},
{"Location":"Clanton"}]
The code below assists in retrieving my current location:
var position = {};
var onSuccess = function(position2) {
console.log(position2.coords.latitude )
console.log(position2.coords.longitude)
position.latitude = position2.coords.latitude;
position.longitude = position2.coords.longitude;
$rootScope.$digest()
};
function onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
navigator.geolocation.getCurrentPosition(onSuccess, onError);
return position;
Based on my current location and the provided data (Location), a check is required to determine which city is nearest to me. This information will be used to sort the data in the View accordingly.