Mike
preOpenStack:
if the environment = "mobile" then
if mobileSensorAvailable("location") then
mobileStartTrackingSensor "Location", false
end if
end if
--- this is a hacked up version of what I use. It should be close.
It compiles but not tested. I have to see if this needs some tweaks using
the new Android permission model.
function GetGpsCords
-- returns
-- Got fix: An array with ["latitude"] and ["longitude"]
-- Bad lock: empty
-- Permission issues: empty
-- Not yet "retry"
local tGPS
if not (the environment = "mobile") then
put 45.338960434184 into tGPS["latitude"]
put -74.6840746841539 into tGPS["longitude"]
return tGPS
else
put mobileSensorReading("location", true) into tGPS
if tGPS["latitude"] is not empty and tGPS["longitude"] <> 0 then
wait .25 seconds -- needed this in the past sometimes on first
location fix
put mobileSensorReading("location", true) into tGPS
end if
if tGPS["latitude"] is not empty and tGPS["longitude"] <> 0 then
return tGPS
else
local tGPStext
switch the platform
case "iphone" -- see what the iOS permisstion status is
put "Location Services" into tGPStext
switch mobileLocationAuthorizationStatus()
case "authorizedWhenInUse"
case "authorizedAlways"
answer tGPStext && "can't determine your location." &
cr & \
"If your" && tGPStext && "was just enabled,
please try again in a few minutes." \ with "OK"
titled "Proximity Search"
return empty
break
case "denied"
case "restricted"
answer "App is not authorized to access"&&tGPStext &"."
& cr & \
"In Settings, please select" && quote & "While
Using the App" "e && "in" && quote&"Location Services" & quote
&& "in this app's settings" \
with "OK" titled "Proximity Search"
return empty
break
case "notDetermined"
if mobileSensorAvailable("location") then
mobileStartTrackingSensor "Location", false
return "Retry"
end if
return empty
break
default
answer tGPStext && "can't determine your location." &
cr & \
"If your" && tGPStext && "was just enabled,
please try again in a few minutes." \
with "OK" titled "Proximity Search"
return empty
end switch
break
default
put "GPS" into tGPStext
answer tGPStext && "can't determine your location." & cr & \
"If your" && tGPStext && "was just enabled, please try
again in a few minutes." \
with "OK" titled "Proximity Search"
return empty
end switch
end if
end if
end GetGpsCords
Ralph DiMola
IT Director
Evergreen Information Services
rdim...@evergreeninfo.net
-Original Message-
From: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] On Behalf
Of Mike for GDC via use-livecode
Sent: Tuesday, November 13, 2018 3:06 PM
To: use-livecode@lists.runrev.com
Cc: Mike for GDC
Subject: finding location on mobile device
I am trying to find my current lat/long on my android device. I have played
around with multiple options including "mobileCurrentLocation" and others.
I have not been able to find an example of code that does it and works.
What I want to do is push a button, have the lat/long displayed so as I can
then "feed" it into a map widget for display. Does anyone have an example
of code that does just that? Thanks. Mike
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode