Page 1 of 2

Mobile Location

Posted: Fri Mar 07, 2014 9:48 pm
by marcelloe
How do I get the current location of a mobile device? I have tried several function to no avail.

Thanks

Mark

Re: Mobile Location

Posted: Mon Mar 10, 2014 10:56 am
by LCNeil
Hi Mark,

We have a great lesson on implementing location based commands for mobile deveices here-

http://lessons.runrev.com/s/lessons/m/4 ... al-compass

Kind Regards,


Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
——

Re: Mobile Location

Posted: Mon Mar 10, 2014 2:14 pm
by marcelloe
I have read over the lesson and could not figure out how to get it to work. The only thing i could get to work was it to respond was true. My next question after i figure it out. How do I convert the coordinates into a location?

Also, When I use the following script on a substack the substack doesn't resize properly.

Code: Select all

set the fullScreenMode of this stack to "exactFit"

Re: Mobile Location

Posted: Mon Mar 10, 2014 4:31 pm
by LCNeil
Hi Mark,

Lesson 4 of the idea2app school will explain how to convert the coordinates into a location (Google Maps). Please watch this lesson and attempt to implement the scripts explained by Elanor.

In regards to locations not working, please supply the stack/scripts you have attempted to use with locations and I should be able to tell you what could be causing the issue.

Your substack will not be resizing as you are you have only referenced "this stack" which will be the stack you are calling the script from. If you want to apply it to substack, you have to define this is your script.

Kind Regards,


Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
——

Re: Mobile Location

Posted: Mon Mar 10, 2014 4:40 pm
by marcelloe
So i have to define which stacks to resize not on each stack script? Also, I have a substack that is 200 by 200 and it keeps resizing way bigger then that. How can I keep the stack the original size.

Where can I find lesson 4 about converting coordinates?

Re: Mobile Location

Posted: Mon Mar 10, 2014 5:15 pm
by LCNeil
Hi Mark,

Yes you will have to define this as substack, although related to the main stack, are still separate stacks.

Lesson 4 is part of the idea2app course with all sessions being part of your LiveCode store account. Please login to your account and these will be available to view at your own pace.

I will need to see your stack/sample script to know why your stack is resizing as it could be many things causing this issue.

Kind Regards,


Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
——

Re: Mobile Location

Posted: Mon Mar 10, 2014 7:45 pm
by marcelloe
This is the script I am trying to use, but i can't get it to work. I am turning off and on the sensor on the card script.

Code: Select all

on mouseUp
  put tLatitude& comma & tLongitude into field "Location" card "LNP"
end mouseUp

on showCurrentLocation
   local tURL
   ## Get the url containing the current location
   ## and display it
   put currentLocationURL() into tURL
   displayURL tURL
end showCurrentLocation

function currentLocationURL
   local tLatitude, tLongitude, tURL
   
   ## Get the current location
   put item 1 of getCurrentLocation() into tLatitude
   put item 2 of getCurrentLocation() into tLongitude
   
    
end currentLocationURL

function getCurrentLocation
   local tLocationArray

   ## If on mobile
   if the environment is "mobile" then
      ## Check the location sensor is running
      if mobileSensorAvailable("location") then
         put mobileCurrentLocation() into tLocationArray
         ## If it is get the current location and return the latitude and longitude
         return tLocationArray["latitude"] & comma & tLocationArray["longitude"]
      else
         ## Otherwise return empty
         return empty
      end if
   else
      ## Otherwise return empty
      return empty
   end if
end getCurrentLocation


Re: Mobile Location

Posted: Wed Mar 12, 2014 11:40 am
by LCNeil
Hi Mark,

In the context of your script, tLatitue & tLongitude are temporary variables so calling them in the mouse up will not work as expected. This will simply put the words "tLatitued" & "tLongitude" into field "location"

You are also calling the displayURL hander within the showCurrent location handler but you do not seem to be handling this anywhere in your script. This will attribute to no values being returned.

something like the following should work when added to your full script-

Code: Select all

on showCurrentLocation
   local tURL
   ## Get the url containing the current location
   ## and display it
   put currentLocationURL() into tURL
   displayURL tURL
end showCurrentLocation

on displayUrl pUrl

put pURL into field "Location" card "LNP"

end displayURL

Kind Regards,


Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
——

Re: Mobile Location

Posted: Wed Mar 12, 2014 8:00 pm
by marcelloe
With adding the new script I can't get the script to produce anything. I am not sure what I am doing wrong.

Re: Mobile Location

Posted: Thu Mar 13, 2014 12:36 pm
by LCNeil
HI Mark,

Please post your stack as it will be easier for us to investigate what could be causing the issue.

Kind Regards,


Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
——

Re: Mobile Location

Posted: Fri Mar 14, 2014 9:24 am
by LCNeil
Hi Mark,

I have had a look at your stack and you have no way of calling any of your location scripts as, even though they are on a button, there is no mouse messages (e.g. mouseUp, mouseDown etc)

Adding the following to your pin button triggers the scripts-

Code: Select all

on mouseUp
   showCurrentLocation
end mouseUp

Kind Regards,


Neil Roger
--
RunRev Support Team ~ http://www.runrev.com

Re: Mobile Location

Posted: Fri Mar 14, 2014 2:32 pm
by marcelloe
Now how do I convert the longitude and latitude to a city?

Re: Mobile Location

Posted: Fri Mar 14, 2014 4:09 pm
by LCNeil
Hi Mark,

This is explained in the Lesson 4 of the idea2app course where Elanor parses location data to google maps.

More specifically, creating a URL that contains the location data- e.g.

Code: Select all

https://www.google.com/maps/preview?q=24.197611,120.780512
Kind Regards,


Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
——

Re: Mobile Location

Posted: Fri Mar 14, 2014 4:19 pm
by marcelloe
I don't want to show the location on a map. I just want the location to be displayed in a field.

Re: Mobile Location

Posted: Fri Mar 14, 2014 5:12 pm
by LCNeil
Hi Mark,

You will have to do this manually as there is no direct way to do this in LiveCode. The process is called GeoCoding with more information be available here-

http://en.wikipedia.org/wiki/Geocoding

Google have a GeoCoding API which you may find useful

https://developers.google.com/maps/docu ... ding/#JSON

Kind Regards,


Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
——