Hi, The script below asks the user for permission to get the GPS location but then does not populate the local Variable tWhereYouAt. (see script below) The next time I click to execute the script it doesn't ask permission and it loads the lat n long into the variable like I wish it did the first time. Any ideas?
The overall goal which I have achieved in TWO button clicks is... get the current location, load the var, alter the HTML, load the google map page url, then stop tracking to save battery life. I would like to do it in just one click. Any ideas?
on mouseUo
get iphoneCanTrackLocation()
if iphoneCanTrackLocation() is "false" then
answer "The devise can not track your location"
exit mouseup
end if
iphoneStartTrackingLocation
put iphoneCurrentLocation() into tLocation
put tLocation["latitude"] into tLat
put tLocation["longitude"] into tLong
put tLat & "," & tLong into tWhereYouAt
-------------------------------------------------------
## do aloto ada stuff TO DA HTML
## query a database for destination info and put it into tWhereYawannnaGo
## Load the page with tWhereYouAt and tWhereYawannnaGo identified on the map
iphoneStopTrackingLocation
end mouseUp
iphoneStartTracking & IphoneCurrentLocation
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: iphoneStartTracking & IphoneCurrentLocation
Hi,
There's a browser message that tells you when the page has finished loading. Use this message to turn off tracking.
Kind regards,
Mark
There's a browser message that tells you when the page has finished loading. Use this message to turn off tracking.
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: iphoneStartTracking & IphoneCurrentLocation
Ok I will work that into the script after the page loads but my concern is the lat long coordinates don't post to my variable on the first pass through the script. Figured I am not doing something right.
I will try a repeat loop that waits a few millisecs on each pass and checks the status of the lat long to see if the issue is that there is a delay.
Was wondering if the lat long coordinates got sent up the message path to the stack or the card and so were not available to my button on the first pass when tracking has to be turned on. It tracking is already turned on then the script operates perfectly. I guess I could turn tracking on when the card opens and then when the button calls for the lat long it will be ready. However then I'm waisting battery life.
Dave
I will try a repeat loop that waits a few millisecs on each pass and checks the status of the lat long to see if the issue is that there is a delay.
Was wondering if the lat long coordinates got sent up the message path to the stack or the card and so were not available to my button on the first pass when tracking has to be turned on. It tracking is already turned on then the script operates perfectly. I guess I could turn tracking on when the card opens and then when the button calls for the lat long it will be ready. However then I'm waisting battery life.
Dave
Re: iphoneStartTracking & IphoneCurrentLocation
Hi Dave,
I suspect that LiveCode doesn't pause the handler for iphoneStartTrackingLocation to execute. This means that the iphoneCurrentLocation function is called while iphoneStartTrackingLocation is still executing and thus returns empty. A repeat loop may indeed be a solution. You can also write a function that calls itself recursively in 200 millisecs until the value returned by iphoneCurrentLocation is an array (with a maximum number of 5 recursions for example).
Kind regards,
Mark
I suspect that LiveCode doesn't pause the handler for iphoneStartTrackingLocation to execute. This means that the iphoneCurrentLocation function is called while iphoneStartTrackingLocation is still executing and thus returns empty. A repeat loop may indeed be a solution. You can also write a function that calls itself recursively in 200 millisecs until the value returned by iphoneCurrentLocation is an array (with a maximum number of 5 recursions for example).
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode