I am creating a hybrid mobile application using the Intel App Framework for the user interface and Cordova for accessing the device’s native functions.
As part of the development, I need to get the user's location (city and country) and show it in the text box.
Using the code below, I can get the Latitude and Longitude and show it in two different text fields (with the latitude and longitude of the identifier). How to translate latitude and longitude to a city and a country.
function Geolocation() {
var onSuccess = function(position) {
document.getElementById('latitude').value = position.coords.latitude;
document.getElementById('longitude').value = position.coords.longitude;
};
var onFail = function() {
navigator.notification.alert('Cannot get the location');
};
navigator.geolocation.getCurrentPosition(onSuccess, onFail, {maximumAge:0, timeout:5000, enableHighAccuracy: true});
}
Note. I do not use any other plugin other than Cordoba geolocation to handle location services in my application. This is a hybrid app, but I'm currently working on a version of the Android app.