Quick and dirty way to get Location data on Mac in Xojo
You could make a Xojo plugin in XCode to access the location data, buy a plugin, or maybe use AppleScript but I think this is simple and will work right in the console using Curl as well as within any language that can issue shell commands. Since it’s Curl it should work for Linux as well.
Create a button and add an Event Handler “Action” and paste in the following code. That’s it
Dim s As New Shell Dim cmd As String Dim ip As Variant Dim city As Variant Dim state As Variant Dim country As Variant Dim zip As Variant Dim coordsArray(1) As String Dim coords As Variant Dim latitude As String Dim longitude As String cmd = "curl -s ipinfo.io" s.Execute(cmd) If s.ErrorCode=0 Then Dim loc as new JSONItem(s.Result) ip = loc.Lookup("ip", "none") city = loc.Lookup("city", "none") state = loc.Lookup("region", "none") country = loc.Lookup("country", "none") zip = loc.Lookup("postal", "none") coords = loc.Lookup("loc", "") If len(coords) > 0 Then coordsArray=Split(str(coords),",") latitude = coordsArray(0) longitude = coordsArray(1) End If MsgBox(ip) MsgBox(city) MsgBox(state) MsgBox(zip) MsgBox(country) MsgBox(latitude) MsgBox(longitude) Else MsgBox("Error " + Str(s.ErrorCode)) End If