Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPSLocation not defined #7

Open
mridah opened this issue Dec 6, 2016 · 1 comment
Open

GPSLocation not defined #7

mridah opened this issue Dec 6, 2016 · 1 comment

Comments

@mridah
Copy link

mridah commented Dec 6, 2016

I installed the plugin using sudo cordova plugin add cordova-plugin-gpslocation and tried using it like :

var options = {
  enableHighAccuracy: true,
  maximumAge: 45000,
  timeout: 15000
}
var data = {};
var watchID = GPSLocation.getCurrentPosition(onSuccess, onError, options);

function onSuccess(position) {
    data['lat'] = position.coords.latitude;
    data['long'] = position.coords.longitude;
    data['error'] = 0;
    data['error_desc'] = null;
    alert(JSON.stringify(data))
 };

 function onError(error) {
    data['lat'] = null;
    data['long'] = null;
    data['error'] = 1;
    data['error_desc'] = error.code + ' : ' + error.message;
    alert(JSON.stringify(data))
 };

But it's giving me this error in the console :

Uncaught ReferenceError: GPSLocation is not defined(…)

Can you help me solve this problem @louisbl ?

@neno-giscloud
Copy link

@mridah try accessing GPSLocation after deviceready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants