how do I get geoLocation on a Mac?

kee nethery kee.nethery at elloco.com
Mon Mar 1 13:34:38 EST 2021


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:

<script>
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 + 
  "<br>Longitude: " + position.coords.longitude; 
}
</script>


I know that macOS can: 
	do <script>  as “javascript”
where <script> is the actual script shown above, not “<script>"

“javascript” is in alternateLanguages() will return true on macOS

Any ideas why the result is "compiler error”? 

I am not a javascript person so perhaps I’m screwing up the javascript or not initializing something correctly. And more importantly, how do I get the geolocation of a mac that is on WiFi?

Thanks,
Kee



More information about the use-livecode mailing list