How to get updated lat and long automatically?

1 view
Skip to first unread message

huangkuan

unread,
Feb 18, 2008, 11:25:05 PM2/18/08
to WHERE GPS Developers
Hi list,

I am wondering if there is a way to get updated lat and long
automatically without refreshing a page? The thing I am trying to do
is to constantly track a user's position. I want to start a new thread
running in the background to keep logging the new lat and long in my
database. I went through the documentation on WHERE but have no luck
so far.

Any one has some idea? Thanks in advance.

Gil Cunningham

unread,
Feb 19, 2008, 9:40:39 AM2/19/08
to WHERE GPS Developers
huangkuan,

If you poke around a little on the discussion forum, you will see that
this topic has been covered. To recap:

1) Create a Thread that runs at some interval to check for the latest
position ...

// runs every 10 secs
Thread t = new Thread("checkAndSendLocation()", 10000);

http://where.com/create/reference/variables.php#thread

2) In checkAndSendLocation(), pull the latest position ...

var lat = load('pos_lat');
var lng = load('pos_lng');

(this unfortunately is not well documented on site)

3) In checkAndSendLocation(), perform fetch() on a <form>

<script>
function checkAndSendLocation() {
var lat = load('pos_lat');
var lng = load('pos_lng');

document.sendPosForm.lat.value = lat;
document.sendPosForm.lng.value = lng;
document.sendPosForm.fetch()
}
</script>

// down here include necessary <form> with id = "sendPosForm"


http://where.com/create/reference/variables.php#form

Hope that helps,

huangkuan

unread,
Feb 19, 2008, 1:20:22 PM2/19/08
to WHERE GPS Developers
Oh, thanks a lot. I should have dig deeper before posting.

phillipr360

unread,
Feb 19, 2008, 4:08:11 PM2/19/08
to WHERE GPS Developers
huangkuan,

One more caveat that Gil did not mention: the (lat, lng) stored on
your device is only updated in JIN once every 2 minutes. As a result,
don't be surprised if the user's current GPS location only changes
once every couple minutes, as this is normal behavior in WHERE.

- Phil

SteveBull

unread,
Feb 21, 2008, 2:38:04 PM2/21/08
to WHERE GPS Developers
I just posted "N95 GPS results with test script" that demonstrates the
2 minute caveat. - Steve
Reply all
Reply to author
Forward
0 new messages