iphoneCurrentLocation() not working

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
tzenobite
Posts: 57
Joined: Sun Dec 04, 2011 3:59 pm

iphoneCurrentLocation() not working

Post by tzenobite » Fri Jan 06, 2012 12:54 pm

hi to all
i can't get the iphoneCurrentLocation() function working
it wasn't working in another little app i wrote last week but i was wondering if i've made some mistake somewhere
to be sure i've just made a new stack with a single card with
on opencard
iphoneStartTrackingLocation
end opencard
and a single button with

Code: Select all

on mouseup
   answer iphoneCurrentLocation()
end mouseup
the stack doesn't work neither in the simulator nor in the actual iphone, even waiting many minutes before click the button
i'm really frustrated, i'm asking if someone here will be so kind to try the same or, if he/she has a stack like this that's working, to send it to me so i try what's wrong
i've all the rest of the stack ready but without the gps working i'm stuck...
please help me!
how many hypercardist are needed to change a light bulb? one to actually do it while at least a dozen more are finding out a slightly different way to do it

proudly hypertalking since 1989

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: iphoneCurrentLocation() not working

Post by Mark » Fri Jan 13, 2012 3:08 am

Hi,

Put this into the script of the first card of your stack. Add one field to the stack. Test on a real device, not in the simulator. Make sure that the iPhone's GPS is turned on and that your app is allowed to track the location.

Code: Select all

on openStack
  if iphoneCanTrackLocation() then
    iphoneStartTrackingLocation
  else
    answer "This device has no GPS or location services have been turned off."
  end if
end openStack

on locationChanged
  put iphoneCurrentLocation() into fld 1
end locationChanged

on locationError
  answer "The location can't be tracked"
end locationError
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

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: iphoneCurrentLocation() not working

Post by Dixie » Fri Jan 13, 2012 3:35 am

tzenobite...

I have attached a stack... It is the scripts from the stack that was posted in the liveCode lessons on the web site, but it works... You can seeing it working well when you go to the shops for milk, or when you are taking the dog for a walk...:-)

be well,

Dixie
Attachments
locator.livecode.zip
(2.38 KiB) Downloaded 247 times

Post Reply