Code pen geolocation not work in a real device


#1

I have try the codePen

and it work fine into the browser; but i want to test it into a device and this not work;
I have installed the cordova geolocation plugin
This is the plugin list in my project

cordova plugin ls
[ ‘org.apache.cordova.console’,
‘org.apache.cordova.device’,
‘org.apache.cordova.geolocation’ ]

After i have build the project

ionic build android

In the ADT i have run the application into a device GenyMotion
All work but not the Find Me button: the $ionicLoading is freezed on the monitor of device as you see in the screenshot at this URL

What i have broken? :frowning:

Thank you


#2

Did you debug your code?

Set a breakpoint in your error case and in your success case.

Maybe the plugin can not get your position and you do not hide the loading indicator in that case.

Greets, bengtler


#3

Did you use emulator?
maybe you need to manually send the gps location to your device.


#4
var options = { timeout: 30000, enableHighAccuracy: true, maximumAge: 10000 };
navigator.geolocation.getCurrentPosition(onSuccess,onError,options);

try add option and check that you’ve manually send location with your GPS widget.
And if you copy all of example index.html you need to add <script src="cordova.js"></script>


#5

This work

Thank you very much


#6

Glad I was able to help. :smile:


#7

can you please tell how to insert this code and where.? I’m having a similar problem where i’m unale to see the map or android device but its working on browser


#8

Find more about this problem here: