Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Get and store GPS location with button press
Started by harvey_thO Mar 25 2016 10:31 PM

4 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

harvey_thO

[GLOBAL: userInfoPane.html]
harvey_thO
  • Observer

  • 3 posts
  • Corona SDK

I was wondering if there is an easy way to get the location of the user when button is pressed. From what I have seen it can only be done by using a listener.

 

 

Thanks!



[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,541 posts
  • Enterprise

No matter what you do, you're going to have to enable location services and that's going to have to have a listener function. It's going to get an event whenever the GPS triggers and you're listener function can set variables that your button handler can later pick up.

 

Rob



[TOPIC: post.html]
#3

harvey_thO

[GLOBAL: userInfoPane.html]
harvey_thO
  • Observer

  • 3 posts
  • Corona SDK

Ok thanks,

Is there a way to reliably make the GPS trigger? I have noticed on the simulator that sometimes it will trigger once and other times it will fire off multiple times very quickly and then does nothing. 

 

Would the GPS start to trigger if I put the app on a device and started moving around?



[TOPIC: post.html]
#4

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,541 posts
  • Enterprise

You shouldn't be getting GPS in the simulator. If there is any location services working, it's just picking up your WiFi info which isn't very accurate.

 

Rob



[TOPIC: post.html]
#5

harvey_thO

[GLOBAL: userInfoPane.html]
harvey_thO
  • Observer

  • 3 posts
  • Corona SDK

ok, thanks for your help. It did seem to trigger consistently while on a device. Using the idea you suggested above I have managed to get everything working.

 

Thanks




[topic_controls]
[/topic_controls]