Paul,
This is a great suggestion. I’m trying simulate the iOS geolocation while I
develop on macOS. Yours is a great idea.
I have gotten the JavaScript to auto load the lat long when I hit the html page
with the JavaScript on my Mac as a file using Safari.
And I’ve gotten the browser widget to load a page from the internet. Could not
get browser widget to load from a file on my Mac without enabling an http
server on my Mac.
Tried putting the JavaScript page on a remote server and hitting it and that
did not work, presumably because the server is not https.
On Wednesday will put the page on an https enabled web site and see if I can
get it to load in a browser widget. Will report back.
But if all else fails, the IP to lat long is going to be a good solution. Thanks
Kee Nethery
> On Mar 1, 2021, at 8:35 PM, Paul Hibbert via use-livecode
> wrote:
>
> I’m no Javascript expert, so I can’t answer the question about the error,
> but my best guess is that code needs to be run within a browser.
>
> However, considering that you need to be connected to the internet to access
> your geolocation on desktop, if you sign up for a free API with
> https://ipgeolocation.io (for unto 30K non commercial Requests Per Month),
> then it’s pretty easy to parse the Lat/Long from the returned data with a
> couple of lines of of simple code, e.g.
>
> put url(https://api.ipgeolocation.io/ipgeo?apiKey=) into tResult
> -- Replace with your unique key
>
> put item 12 of tResult && item 13 of tResult into tGeoLocation
>
> The result = "latitude":"50.12345" "longitude":"-125.67890”
>
> It’s not quite as accurate as GPS, but it’s close, plus you have the
> advantage of lots more data returned should you need it and no messing with
> Javascript.
>
> Paul
>
>
>
>> On 1Mar, 2021, at 10:34 AM, kee nethery via use-livecode
>> wrote:
>>
>> How do I get latitude & longitude within a macOS LiveCode script?
>>
>> ———
>>
>> I know iOS has a way to tell you latitude & longitude. It appears that
>> capability is not available on macOS.
>>
>> I know that macOS browsers, with WiFi on and connected, can determine
>> lat/long with a javascript command. At this URL:
>>https://www.w3schools.com/html/html5_geolocation.asp
>> I found this example:
>>
>>
>> var x = document.getElementById("demo");
>> function getLocation() {
>> if (navigator.geolocation) {
>> navigator.geolocation.getCurrentPosition(showPosition);
>> } else {
>> x.innerHTML = "Geolocation is not supported by this browser.";
>> }
>> }
>>
>> function showPosition(position) {
>> x.innerHTML = "Latitude: " + position.coords.latitude +
>> "
Longitude: " + position.coords.longitude;
>> }
>>
>>
>>
>> I know that macOS can:
>>do