Software Archive
Read-only legacy content
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
17060 Discussions

Cordova geolocation Android

Gerald_C_
Beginner
1,264 Views

Hi everyone,

I'm having an issue with Cordova's Geolocation plugin on Android devices (and the emulator too).

First off the plugin works fine on the iphone emulator but when I try to get my location using the code:

var suc = function(p){       
        if (p.coords.latitude != undefined)
        {
            if(!is_requesting)
                findEvents(p.coords.latitude, p.coords.longitude, isForMap);          
        }
    };
    var fail = function(errorObj){
        alert("geolocation failed");  
    };
    var options = {
        maximumAge: 90000,
        timeout: 50000,
        enableHighAccuracy: true
    };
    navigator.geolocation.getCurrentPosition(suc,fail,options);

On Android this just times out and give me the error object message:
"Timeout expired"

I've tried setting enableHighAccuracy to true (and false) but neither seems to fix my problem.

Any help on this would be greatly appreciated!!!

Many thanks!

0 Kudos
1 Solution
Anusha_M_Intel1
Employee
1,264 Views

Please take a look at Question 21 on the this FAQs page and see if it is of help to you: https://software.intel.com/en-us/xdk/faqs/cordova

Q21: How do I resolve Geolocation issues with Cordova [Plugin]

 

View solution in original post

0 Kudos
5 Replies
John_H_Intel2
Employee
1,264 Views

Did you enable to Cordova geolocation plugin?

0 Kudos
Gerald_C_
Beginner
1,264 Views

Yes I enabled the geolocation plugin as the plugin works fine on iPhone emulators....

Only on the android emulators and phones, I am unable to get a geolocation...

0 Kudos
Anusha_M_Intel1
Employee
1,265 Views

Please take a look at Question 21 on the this FAQs page and see if it is of help to you: https://software.intel.com/en-us/xdk/faqs/cordova

Q21: How do I resolve Geolocation issues with Cordova [Plugin]

 

0 Kudos
Gerald_C_
Beginner
1,264 Views

Thanks Anusha!

Weirdly enough, when I actually built the app and installed it on my phone (so not using the emulator) the app was able to retrieve a GPS coordinate so I think that possibly the plugin may not work on the emulator!

 

Thanks again tho, that FAQ looks really useful!

 

0 Kudos
Anusha_M_Intel1
Employee
1,264 Views

I am glad it worked out for you and Thank You for your support!

0 Kudos
Reply