Tommy B
Posts: 0
Joined: Sat Sep 15, 2012 3:39 am

jquery script for location services

Would like to use the following java code on my main page "on load" event to detect if gps is turned on or not. I think that the script is good its just how to put it into the tiggzi javascript function window that im having issues with. I am thinking that its all about the function () tags. Any help would be great.

function initiate_geolocation() {
navigator.geolocation.getCurrentPosition(handle_geolocation_query,handle_errors);
}
function handle_errors(error)
{
switch(error.code)
{
case error.PERMISSION_DENIED: alert("GPS function not available right now");
break;
case error.POSITION_UNAVAILABLE: alert("Location services not turned on! Please enable location services prior to continuing.");
break;
case error.TIMEOUT: alert("retrieving position timed out");
break;
default: alert("unknown error");
break;
}
}
function handle_geolocation_query(position){
alert('Lat: ' + position.coords.latitude +
' Lon: ' + position.coords.longitude);
}

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

jquery script for location services

Hello! You have to call initiate_geolocation() function. Try to put next code on screen Load:

initiate_geolocation();
function initiate_geolocation() {
navigator.geolocation.getCurrentPosition(handle_geolocation_query,handle_errors);
}
function handle_errors(error)
{
switch(error.code)
{
case error.PERMISSION_DENIED: alert("GPS function not available right now");
break;
case error.POSITION_UNAVAILABLE: alert("Location services not turned on! Please enable location services prior to continuing.");
break;
case error.TIMEOUT: alert("retrieving position timed out");
break;
default: alert("unknown error");
break;
}
}
function handle_geolocation_query(position){
alert('Lat: ' + position.coords.latitude +
' Lon: ' + position.coords.longitude);
}

Tommy B
Posts: 0
Joined: Sat Sep 15, 2012 3:39 am

jquery script for location services

Thank you. I works now....but im sure you knew that.

Alex GG
Posts: 0
Joined: Thu Nov 14, 2013 11:11 pm

jquery script for location services

Hello,

I ́m using this code to alert the user to turn on the location services in order to show the nearest places..

But I ́m just showing a dialog message...which is useless..

What I want to do is what I have seen in google maps and in other apps..

is a popup that takes you directly to the location settings, or cancel.

like this,

Image

Can someone point me on how to achieve this?

Regards

Alex GG
Posts: 0
Joined: Thu Nov 14, 2013 11:11 pm

jquery script for location services

any comments here?
Thanks

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

jquery script for location services

Hi Alex, you should check if this possible with PhoneGap:
:: http://docs.phonegap.com/en/3.3.0/cor...

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

jquery script for location services

Hello Alex, this is system dialog, you aren't allowed change it

Alex GG
Posts: 0
Joined: Thu Nov 14, 2013 11:11 pm

jquery script for location services

HI! Sergiy. I have seen apps with different messages like the above, even with the app name...

Lets say I cant change the dialog, how can I remove from an alert message the "pagename.html", because I want to ask user to turn the locations services on..

thanks

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

jquery script for location services

What kind of dialog you're seeing now?

Return to “Issues”