Geolocation and accuracy

Hi all,

I know my question isn’t a real ionic question. But since you all are a real helpfull and smart bunch I’m going to post it here anyway. :wink:

I want to include geolocation in an ionic app I’m building. When the user comes near a certain location the app should know and do something. Al the examples seem simple but getting accurate results apperantly isn’t.

I’ve been reading up on geolocation and some people say not to use the cordova plugin but use native browser geolocation.(cordova uses native anyway?) Then there is the issue about accuracy, getCurrentPosition isn’t always that accurate apperantly. Even with highAccuracy set to true (because it doesn’t always wait for the gsp to come up?).
This guy https://github.com/gwilson/getAccurateCurrentPosition wrote an enhancement on it using watchCurrentPosition giving better results.

Well my question is. Is there someone who has built an app with accurate geolocation and could he or she give some insights on how they did it.

Thanks

Hello,

Yes i used it on my previous app (without ionic), here is my code :

document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
navigator.geolocation.getAccurateCurrentPosition(onSuccess, onError, onProgress, {desiredAccuracy:300, maxWait:10000});
}

function onSuccess(position) {
lat = position.coords.latitude;
lon = position.coords.longitude;
updatep1(0,lon,lat);
}

function onError(error) {
alert('unavailable GPS');
}

function onProgress(param) {
}

Hope it will help you

hi,
can u tell me how to get the accurate location all the time.
because my application is fully relaying on the location.
its kinda like an tracking application.
if u help me in sorting this problem it will be help full.

thanks in advance :smile: