Page 1 of 2

Geolocation to Picking Location

Posted: Tue Oct 09, 2012 6:16 am
by Jerry Levine

Hiya...

This may be out of the scope of the forum, but...I hope someone can help!

Basically, what I want to do (and not display a map, although I suppose it can be hidden) is the following:

1) Geolocate user
2) Based on user's location, display a specific item - essentially, "I think you are here - is that correct?"
3) Upon press of Yes, go to a specific webpage
4) If No, present selections of other locations and then go to their webpage.

I can figure out (4) - it's just a list. But I kind of need help with 1-3...


Geolocation to Picking Location

Posted: Tue Oct 09, 2012 10:29 am
by Maryna Brodina

1) You can try to use this code:

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);
}

2) Use $(document).simpledialog( to call the dialog - this shoul help http://dev.jtsage.com/jQM-SimpleDialo...

3) You can add events on click "Yes" button (here is more information http://stackoverflow.com/questions/50...)


Geolocation to Picking Location

Posted: Tue Oct 09, 2012 1:13 pm
by Jerry Levine

Marina -

Thanks. With regard to (1), I'm presuming that goes in the Custom Javascript field, and I could call that at Load?

Thanks,

Jerry


Geolocation to Picking Location

Posted: Tue Oct 09, 2012 1:28 pm
by Jerry Levine

Solved, the answer is yes, of course.


Geolocation to Picking Location

Posted: Tue Oct 09, 2012 1:48 pm
by Jerry Levine

Marina - I think that this might be a function of my limited programming knowledge. I might just need to find someone to do this for me.

Tiggzi seems to be simple, but I just don't know how to effectively use code to do things that are out of the realm of the main interface. :(


Geolocation to Picking Location

Posted: Tue Oct 09, 2012 1:59 pm
by Jerry Levine

This is just a function of me quitting CS to go to business school. Now recognized as a bad decision. :)

I can visualize what's supposed to happen - , I can tell that it's determine location lat/long, request ZIP based on lat/long, look at array for matching ZIP code, display specific location based on array, else, offer list based on state/locations...

I just don't know what the heck I'm doing. Hah.


Geolocation to Picking Location

Posted: Tue Oct 09, 2012 3:11 pm
by Maryna Brodina

To work with Tiggzi you should have some knowledges of HTML, JS, CSS, but don't be frustrated! Did you try sample above? What exactly doesn't work?


Geolocation to Picking Location

Posted: Wed Apr 23, 2014 7:34 am
by Puneet Duseja

Hi,
I would like to know if i can display the user location on my app screen, using the above mentioned java script.

copyin here as well...
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);
}

Thanks


Geolocation to Picking Location

Posted: Wed Apr 23, 2014 9:32 am
by Maryna Brodina

Hello!

Have you tried this code? Are there any problems?


Geolocation to Picking Location

Posted: Thu Apr 24, 2014 11:37 am
by Puneet Duseja

Hi, I tried this code and it works fine, as it displays the latitude and longitude. I want to know the name of the location or city and display it in a field on the application. Could you please let me know how that can be achieved. Thanks!