I am pretty new to Cordova in general and never dealt with this stuff before, so I need some help and pointing out.
I need to use geolocation so the app can detect where I am and propagate the result to a textbox, so the user doesn’t have to write his address hims self. Also show on the map in the later process (where the user is)
This will need to be done using both geolocation and geocoding, does cordova provide geocoding, or I need to take some other approach?
Can I have some successful code examples, tips, suggestions and pitfalls when dealing with this services/APIs/Cordova/what ever they call them self.
But I can use both is that correct? Cordova Geolocation and Google Map Api? Unless it’s not recommended and should just use all of the Google Maps Apis that come with it?
How do I display the marker of my current location? On Success I want to get the position and make the marker that will show were the position is on the google map
@cameronbourke What do you use for google map? I am going with Angular Google map, are you using the same? I will try and see how your implementation fits in with angular google map, should be more or less the same. Thanks!
Need help with ngCordova, I am trying to get the position and reverse geocode to a string that can be displayed in the view. But nothing happens when I test it on my android device. If I do it without ngCordova and go for a google maps api options, then it works in the browser but not on the phone.
What I am doing wrong?
function HomeCtrl($ionicPlatform, $cordovaGeolocation, myDriveApi) {
var vm = this;
$ionicPlatform.ready(function(){
alert('device is ready');
vm.myLocation = "";
var geocoder = new google.maps.Geocoder();
var geoSettings = {
frequency: 1000,
timeout: 30000,
enableHighAccuracy: true // may cause errors if true
};
$cordovaGeolocation.getCurrentPosition(getPos, error, geoSettings);
function getPos(position) {
var LatLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
console.log(LatLng);
return showLocation(LatLng)
}
function error(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
function showLocation(LatLng){
geocoder.geocode({'latLng': LatLng}, function(results, status){
if(status == google.maps.GeocoderStatus.OK){
vm.myLocation = results[0].formatted_address;
console.log(results);
}
})
}
});