Book Image

LiveCode Mobile Development Beginner's Guide (2nd Edition)

Book Image

LiveCode Mobile Development Beginner's Guide (2nd Edition)

Overview of this book

Table of Contents (15 chapters)
LiveCode Mobile Development Beginner's Guide Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – making the location card work


The Location card has three fields in it for latitude, longitude, and a title for the location. The user could type in the details manually, but if they happen to be at the location in question, there's a button there that will grab the location and fill in the numbers automatically. The following steps will guide you in making the location card work:

  1. Edit the script of the Set to Current Location button and type in the following lines of code:

    on mouseUp
      mobileStartTrackingSensor "location", true
      put mobileSensorReading("location", false) into tLocation
      mobileStopTrackingSensor "location"
      set the itemdelimiter to comma
      if the number of items in tLocation = 3 then
        put item 1 of tLocation into field "latitude"
        put item 2 of tLocation into field "longitude"
      end if
    end mouseUp
  2. Nothing too tricky here; we just captured the location and stored the latitude and longitude entries in the two fields.

  3. Edit the script of the Cancel button...