My question is simple : I want to know where to begin to add geolocation in my application.
I want that when the user arrives on my application, its location can be requested and saved. Then, my application would offer him the nearest posts its location (With NG -repeat ) .
The user can create his own post and specify the address, the city of his choice , which will be converted into latitude and longitude data in the database .
I wonder if there are tutorials to achieve this result . What tools should I use to do it and if possible a source code that I can inspire me.
I already looked here :
https://github.com/firebase/geofire-js
https://github.com/arunisrael/angularjs-geolocation
https://github.com/apache/cordova-plugin-geolocation
And a lot of tutorials, but I haven't found one who really help me.
Is this a good choice ? I use Ionic with AngularJS, and Firebase.
Thank you all for your next contribution.
NgCordova is an excellent library and made by the same people as ionic. It allows you to use various native plugins in an angular way.
To use geolocation with NgCordova, just follow the instructions at http://ngcordova.com/docs/plugins/geolocation/ and the $cordovaGeolocation object will return a promise that contains the latitude and longitude coordinates as shown below.
var posOptions = {timeout: 10000, enableHighAccuracy: false};
$cordovaGeolocation
.getCurrentPosition(posOptions)
.then(function (position) {
var lat = position.coords.latitude
var long = position.coords.longitude
}, function(err) {
// error
});