NARESH REDDY
NARESH REDDY

Reputation: 682

how to check gps status in phonegap?

I want check whether GPS enabled or disabled in phonegap.

and display an alert when the GPS status changed

I have done this in android.

Upvotes: 1

Views: 1423

Answers (1)

bhb
bhb

Reputation: 2561

From the phonegap docs

var watchId = navigator.geolocation.watchPosition(geolocationSuccess,
                                              [geolocationError],
                                              [geolocationOptions]);

You might want to do something like this(untested)

navigator.geolocation.watchPosition(function(position) {
    alert(position.coords.latitude) //or logitude and etc
});

and if you want to stop watching

geolocation.clearWatch

Have a look at this or this, could be helpful.

Upvotes: 1

Related Questions